{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# §7 Symbolic mathematics\n",
    "\n",
    "## Contents:\n",
    "\n",
    "    7.1 symbol\n",
    "    7.2 numerical value\n",
    "    7.3 function\n",
    "    7.4 expression\n",
    "    7.5 calculus\n",
    "    7.6 equation\n",
    "    7.7 linear algbra\n",
    "    7.8 number theory\n",
    "\n",
    "Reference:\n",
    "\n",
    "https://www.sympy.org/en/index.html\n",
    "\n",
    "https://github.com/sympy/sympy/wiki/Faq"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.1 symbol"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'sympy.core.symbol.Symbol'>\n",
      "True\n",
      "Abs(x) y\n"
     ]
    }
   ],
   "source": [
    "import sympy\n",
    "\n",
    "#use_unicode=True\n",
    "sympy.init_printing(use_latex=\"mathjax\") #It does not work in my computer\n",
    "\n",
    "x = sympy.Symbol('x', real=True)\n",
    "print(type(x))\n",
    "print(x.is_Symbol)\n",
    "\n",
    "y = sympy.Symbol('y', positive=True)\n",
    "print(sympy.sqrt(x**2), sympy.sqrt(y**2))\n",
    "\n",
    "a,b,c = sympy.symbols('a,b,c')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "key words of symbol"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True False\n",
      "None True False\n",
      "True\n",
      "True False\n",
      "True\n",
      "True False\n"
     ]
    }
   ],
   "source": [
    "print(x.is_real, x.is_imaginary)\n",
    "print(x.is_positive, y.is_positive, y.is_negative)\n",
    "\n",
    "x2 = sympy.Symbol('x2', integer=True)\n",
    "print(x2.is_integer)\n",
    "\n",
    "x3 = sympy.Symbol('x3', odd=True)\n",
    "print(x3.is_odd, x3.is_even)\n",
    "\n",
    "x4 = sympy.Symbol('x4', prime=True)\n",
    "print(x4.is_prime)\n",
    "\n",
    "x5 = sympy.Symbol('x5', finite=True)\n",
    "print(x5.is_finite, x5.is_infinite)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.2 numerical value\n",
    "\n",
    "number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'sympy.core.numbers.Integer'> <class 'sympy.core.numbers.Float'>\n",
      "<class 'sympy.core.numbers.Integer'> <class 'sympy.core.numbers.Float'>\n",
      "8663234049605954426644038200675212212900743262211018069459689001\n",
      "8663234049605954426644038200675212212900743262211018069459689001\n",
      "2.2999999999999998223643161\n"
     ]
    }
   ],
   "source": [
    "i = sympy.Integer(19)\n",
    "f = sympy.Float(2.3)\n",
    "print(type(i), type(f))\n",
    "\n",
    "i2, f2 = sympy.sympify(19), sympy.sympify(2.3)\n",
    "print(type(i2), type(f2))\n",
    "\n",
    "print(i**50)\n",
    "print(19**50)\n",
    "print('%.25f' % f2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "rational number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACEAAAAUCAYAAAADU1RxAAAABHNCSVQICAgIfAhkiAAAAdVJREFUSInt1U+ITmEUBvCfGWl2k78zG4mVhVLKUsLCQqNkZ2NBUkqTlFIyG/+ilC+zNLOxIlb6FlLyp9SoD4NJURMRhYgSRmPxni/XeO8395OF5Knb7Z7znOd93nvfcy5/GeZiOy7iMT7hPW5gGzpa1PbgG04VYsdwBc9C6y0aOBhrZbETk3iBsziCM3gX8fOYUVK7IzhrCrEvuBUaR1HDSPCeY2FOaC36/LrjXjyN4s0lJup4jc5CrKuEeyi0BkvypdgfhbVMrhufMVRRa3loXW4GWn3nIr7GfSKT24BZuFBRqy/u9yrywUyMSu7XZ/Ln8FH569+LAZzE9dC5i/ntmDgRhZcyuS58CCNleBn1zasudVNl7I7CMczJ5DdGfksFrR5swiOpA1dUMbArFnggdUgOQ9Kh7K4iGFgUNfenI/aHgVEsKOF0Sm1Zb8NAE43Qn1dG2BeERiuSNJgmpUHVLl5F7exc8kAkb8ufgSJq0qjOHbKl8p+ww49hdbMZLI7hrRgO4Zr035iK8eCQ/gnjWJXh9eM4ruEJ3oTZ1Vgidcw6PJxaOODnVspdV4O7Mp73ZAzAMpzGHencTMSmRmKd6d5yJRwOE4v/hNjvYkza5X/8e/gO2Wl7QOZLr7AAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\frac{2}{3}$"
      ],
      "text/plain": [
       "2/3"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r1 = sympy.Rational(4, 6)\n",
    "r1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGEAAAAVCAYAAABWtYB0AAAABHNCSVQICAgIfAhkiAAABDdJREFUWIXt2WuIVVUUB/BfY8kMGppZRhAk5LMBsRcVKNPDgkJLyA9FkhHUhx5k9CUINCotkYLsAYIlEkRkL7IspeiBlAZpBYlEpoxlmaX2YHpo04e1L3PndM655+pNJeYPw76s115r77PXWnsPAzhqsQK7MORIO/I/wtnoxU1VhM/B37grQ78GS/ABfk4Gn63owCgcwGN1tIfxNrrRg5+wEfNwYkW7zWCO8Lns70CJfl4MNUzBi9iJP9K4Bldk5F5OvKH1xGNzDC4Qi/xUhn4vJuFX7MD4EoezuAptyYka5uITrNV36s7HfNycfnc3MUcjbMJ9BbwpuBirS/TzYiDW5X7sxiqxyCMxGV14o052IdbjDrHOuRgrTsHSHN5FGINjkvFmTsLq5OSgOlp7geyDyfaTFW23Ah+mOWeUyOTFMCvprcXxOTrH5dA2Y3vGTj88lIxeUupyc5swTBzRZyrIEqetFtjhQGeab4fihcmLoQ1b8RtOamK+eWm+y2uEbDq6VOS9j5ow2ghXYjBeqig/PY2ftdCHMtySxmWKa0JeDBdiNFZiT5LpxO/YIE5XHtalcRreyjKHYD8+r+B4l+on4QVRR4rSz92iDjwqin4vPtXc13Ww6BALeACnlcjlxTBX+Pq4+GCyRf49+TEMS/wNeRONTcw1FZzvUm0T2vFLCqII3+nv/GrRiRwO3JDmXFUiUxTDwqS7H1+KFD4UZ+LNxHu3wGaPiPtfuCApPl/B+S7VNmFGkruugs1RmIkt+BZnVdA5VKwT/k0vkSmKYZG+tnZShtchOrtesa5ZfCM2D1FcauhJY1HaOBjMxJ94vYLs96L9u0zcE1a00I88TBR5fYf+bWQWRTHsSeNWkT7r0aMv35+XY7ND33r324RdaWzVRWmQ+MLewb4m9LbjC3GsR7bIlzxUKchlMWxJ494C3domdWTobRiub737bcJO/IBxRV43ialiQ7OXmyo4NY1lN9hDQTtmizvRshK5shjeFylljOicsuhM47YMfZy4a20qmnSlyGNnlDhGtZqwRCxiXpEdj1Ny6G36LmvrMrzliT6ngW9VMDvZeq2BXFkMRPy9eCBDnyY2eK/46utxY9K5rWjSa5PArTm8q8VCLNdX/b+qoy3OyHeLljMPd+Iv8Xa0VHQaTyd7veJUTszorEi864ucbwK1VrisIFMeA5wsOqNecTIWiy5qv4hvVo7Oc4lf2BIPFq3T+hzefOWPX9vqZM9NtOwjYA2deEIcyd3JqX34OM0zIkdno3jTOqHI+YqYkHzrVvJ0oHEMNYzAI/haFPAf8ap4+8pimCjIrzRy8p40+eRGgiVYkGyMPgQb9Rgu0sKiFtmrglbHALcnm1MaCbaLDqVRvizDZiWF5yAwXTwH5NWR/wqtjqFD3H9WVlWYKh6aBv6p0zpMEKn29CPrxgAGcLTiH4leKP6FSVB9AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left( \\frac{1}{3}, \\  \\frac{7}{6}\\right)$"
      ],
      "text/plain": [
       "(1/3, 7/6)"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r2 = sympy.Rational(1,2)\n",
    "r1*r2, r1+r2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "constant"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAI4AAAAXCAYAAADdlHeDAAAABHNCSVQICAgIfAhkiAAABJJJREFUaIHtmm2IlFUUx3+6vuy6wmYvFBX2wrJma2SZ9SEttGX7EAVtkUR9yAIJ0bA3waA3KIIIMnrRCiMry6iwsBeykKK1UqLWMi1Mo5BcStoo2U0ztw//c/PZO3OfnZ3nzgzLPj8YHubce885d+aec8+9M5CTE5EXgF+Bxlo7MoK4DegHrq21IwlmIJ9uKqXzecBhNJGc6vEy+pJaau2IxzpgLzBxsI4bgD+Ahkp7lDOAycAZwKhaO+JxPlrQd6V1akHZ5plqeJQzbNgB/ATUOcFor8ONaMW/6skvQ6uulNf0Cjh+FfAesA84COxEEVCXNqgMOoB/gM3AKYE+96N5Lohod47pfDiizpisRRmxLdThC+AQhUXxLOApNLltwH2J11qTfwLcQ+FizEId8Irp3wmsAJYD35tsdURbABcC75ruJ4u0nw70AVuIO8/bqVxhfD3KFn3AS8AEk89B33cPCsrJKTrazL9HijU2okXzTWDwlTb4AU++lCFU3kPkCdP9EDAmIR8LbLK2MyPbHA/sR1nH523gX3SAiMkaNJcpkfWehbL0NUA7sAt4H2gFeoGVwMXAY2gRheqrJvNvS7HGFmvcEBjsUvTVntxlnBklTaV0LkD11puB9gVmd35ku6AP6E9PdoXZW1EBezuAv4ibxQCeA25JvG8FDgDdwGte38+BuSm6+mwcMDCKj7FnT2Cgq122evJzUabalmK0HBajCOhFW6LPNHtW4hTyHTATOBnYg06Yy1H0pp4uyqARBe2nKFBiMg1lE8e3wCoUdEu9vp1oYW0M6PodON69SS6cPnvWBwZORyn8h4RsItBsDh0Iul8e7fYcbN//ObJd0MIBbYN7gGXAaWg7DgVWuZyNMs2XkfWCgqrfk+1GteNxwI8JeT/pQdjAkTUygBNtcGeRtknWtsmTzzb5iykGy6He9H4cWW+pdJj9JRwpiD+jMtltkdm6oQK6VwMLE++bUCD8BnzEwPlsBi4J6BmNsuEuJ0hmnL2msFiBlrZNAXQFXS8PN6FjI+stlWTGaUPF+EIKozcG7jOsRMZ5FPgAbbHdwIPohHUzWiir0Gm5AwVraJuagr6T4Pf8Ovpwmj35rRS/u3jW5O0U8jzZImmrje8ItM+i8B4nq03HOFS39Zi+x1P6ZrXZhTLaGE+eVa/jOrRY9qODhqtT5qKy4zA6DExN0THffFnkBL6zb6DLtksZWMuEMs7R9mwFtqM06HAnhEMpDqVxJ/CO+fQh8LXpPAmd4MZSePeQ1abjINr/m9GPvXen9M1iczzKal1Fxseayxp7+WxE83PbUBrt6BrirVCHcSil+XcYXTZwgiefh9JgL3CH1/YVOtJOGsSpNGaiLNiNbnT3oXumpym+H8ew6VhPaRGfxab79XllZL0xaUIZMXQt8j/L0GTOyWDsKLTQqnmFHttmp+lL+2tJpeZZi88vxGK0HmYP1rEe7YnrMxi7HPgbOCGDjlraHIUu5LZX0WY19A6VBuAXlPVL4iLgXkbuH7ncLXqx2mAkMRVdvp5aWzeGD/PQwvHrtpycnJycnJzhwX93HR+Ujtv03AAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\left( \\pi, \\  e, \\  \\gamma, \\  i, \\  \\infty\\right)$"
      ],
      "text/plain": [
       "(π, ℯ, γ, ⅈ, ∞)"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.pi, sympy.E, sympy.EulerGamma, sympy.I, sympy.oo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "True 0 oo\n"
     ]
    }
   ],
   "source": [
    "print(sympy.E**(sympy.I*sympy.pi) + 1)\n",
    "print(sympy.oo>9999999, 1/sympy.oo, sympy.oo+1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.3 function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'sympy.core.function.UndefinedFunction'>\n",
      "f(x)\n",
      "g(x, y)\n",
      "{x, y}\n"
     ]
    }
   ],
   "source": [
    "f = sympy.Function('f')\n",
    "print(type(f))\n",
    "print(f(x))\n",
    "\n",
    "g = sympy.Function('g')(x,y)\n",
    "print(g)\n",
    "print(g.free_symbols)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "120\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "print(sympy.sin(sympy.pi/2))\n",
    "print(sympy.factorial(5)) # 5!\n",
    "print(sympy.binomial(5,3)) # C(5,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEsAAAAYCAYAAACyVACzAAAABHNCSVQICAgIfAhkiAAAArBJREFUWIXt10uoTVEcBvCfR9zrdcujECOXkEciJUxQSjGQkhkZYsKIicfEzWNiQBlJSYooE+4YeeWRYkTHgIuryMDN8xqsdbvnXvvsva5zcOh8tTpn7f+3v/Wt/1577f+igQYysBt38AGduIw5f9VRHeMqtggJmouLeIWx1QqfxhuMrFaojjEK37C23/WF6MbWFJFF+I6dNbVWf5gkJGVpRuwiOoSE5qId79FcU2v1h3O4jyEZscVCIvfkCcwQVtXJmlurLxwWVk5rDucJnstOJmgTMroyI9YeY+v7XR+EUzHWVkF3I9blGOtBK8Yl8KrxdBSvMbtAe2+8f3Ulwl18lb2xzxc2xMf6ZvtoFM1bjSXcLDDXghd4ID1hA/V0TFqiYFXUOJIVHCkk6lGOwKkosDn298T+OQzOua+kOFmwK+o9xPgE/kA8HRdqrBWYWNYqbeItUed2VnBGDLbnGJuCLmHy2yP/CoblzSbyb6Epoe02sISleuqu0PblaHcJtdhPWKL3ieThYNlA1zGigE+YSCWzee1ygvavekrBC+FtA0PLAl3xt6lAoLPs/1Z8TBz4rVBFF2G03o9ByqtbjaciNOvNSx9MFp7MtZybNwmlRUfknkgctCRt4mNwI2ofSNT+VU9FGBx1n2YFBwlHnM6sINbgs/ABmCDUIV8wM2HgkuJkjYqcbuxP0KzWUxFmRS8XKhHOR0L/Ym2ZsLSfCccE2BC5lxIGLilO1hCckZ6oaj0VYUvU2l6JsCkStpVdmy8cfzowrR//TuQvr4E5wupOwZ/wdFbY3KdWIgwTPpW3Yr819t9hXga/p3BL3YhrgT/hqUXY2AtXaE+ds6CKwf517JC4OpuEA2RqjfO/oRkvhf27D7JO1F9xD8OFs+KX32qt/jAdn3BI2BcbaKCB+sEPtV/XUosGH/4AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left( x \\mapsto x^{2} \\right)$"
      ],
      "text/plain": [
       "     2\n",
       "x ↦ x "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.init_printing(use_latex=True)\n",
    "sympy.init_printing(use_unicode=True)\n",
    "h = sympy.Lambda(x, x**2)\n",
    "h"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABoAAAASCAYAAABFGc6jAAAABHNCSVQICAgIfAhkiAAAAVxJREFUOI3t1D1LHVEQxvGfQVBSWKioVSxMp+BHEGxExEIlnWihXSDYKYLoB7AQLLSwsLO00sZCEUshoPgCSnKxSSAIiiaKb9dij3Bddr33bpPGgcMuO/+ZZ4YzO/wHq8MoVnGKG1xiByP4kBCTQz7l/C4EKwvev2ABv7CJMzSiH0voDkw+JnaJuYQirtM66kRvQuVNQTSPgYSOcmkJs9hkEJrPKlRZHAH34fmQ4KvCID7hL/awjccSc78qZl/UUVfMl5M8CD/QUa7QbAheS/BNi+62ER/RhkU84R/aSxX5FkSOUJuhuNVS4K8BPhBNXjn2OcSeFwPHAriPhjJFoCbE374FjQfoO+oziBANTR6HacBUAHYVv5PWFKYZJyHP5MvHigJgGMui+Z8XrZa45QIDM5gQraufuEILelCNdfThLp5kRvqCfDlbBXwHVnCMC9FP/QcbGIo18W7Z7RkZc2OohXYbCQAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle 25$"
      ],
      "text/plain": [
       "25"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "h(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEsAAAAYCAYAAACyVACzAAAABHNCSVQICAgIfAhkiAAAAs9JREFUWIXt10+IFnUcx/GXFuaqsBIeKrRL6kpYKkYkJWwlHgJRwouXeGq7aRdvCoI3wxKioMDTFoIuBAZedC9CFlSKCZEFGWxgrukhKUhE7fHw/W1Os88zz+zM9uwGzxuGmfnNZ77f73zn+/tHjx4V2IOz+APXcQKrZzSiWcwpvC4S9BSO4yoe7vTiJ7iGhf9ldF1mPZoYKqlfhLvYUiR6Bn9jd63QusN2fIAzovs0caRAfxzjIhGdeDTZe75INIob6CthcKa5ID7oT/ygc7KeTZq9JWyP4Fs80E6wUlTV4ZLB1qUhgh+s+P6LWIE5yUanZBFJ/UVBEvCOqMDl2ca5OdEbyfFICwOjKZhXc+1zMJyevd0h0OnmNH5KvstyDI9jU5vnh/AaXsalIkPncEfrgX2NGPAu+vdfOZSCrVKNDfUqK8ugcpW1KenebfHsffyGJzs5WygS9V2BZjg5aqT7vel+xOQqLUND95PVn3Tf5No/FJPES3gkc7ScDFYmI6MFjpbiJsawK+lPYl6HANvR0P1kEd9wNdfWbHPsb2Vgg/tVUsSBjKEvsaBEcESC2wXU6hguaXeCQeWT9avoRVPiwcz1zXSe3+Gd65nrIfxV0td7WJxrW4ut+FgkM8uFknar0Of+91biMfFnvijQ7BBLi/Gk/aiOQzPTDeeKb/h5qg6yg/K4qJqBNtpXRAV8j6fxI97Eqqk6nWEGxHJnypWbTVYTn2OJ3GIML+BTXMZmkdR9oht3e21Vl+fS+XRdQztE0nZm2taI7c84nsjpzyb9xor+Gup1w21iIhgWs3JTdK+JtlZrqaNicF9W0ec/zBNT6tfpfnm6/110vTwTC7yvKvprqJes/Ypn1LGcvl8M7J9V9DeJPcnRuukyOIt4S72eMIn5YqN5YroMzhL6cEWMvZVotfO+g/N4SOwVb1c1PstYgVs4KMbgHj16/P+4B5qxwb5YvgnvAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left(x + 1\\right)^{2}$"
      ],
      "text/plain": [
       "       2\n",
       "(x + 1) "
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "h(x+1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.4 expression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIQAAAAWCAYAAAAB6jTvAAAABHNCSVQICAgIfAhkiAAAA6ZJREFUaIHt2WuIVVUUwPGfD0rCInpZEBRkEZXVh74ElaMVohGK6Qch8oRBH4wKKiopkihGyGBKSKE+TBBEEBj0oBcYTC9ISBIqKOwWgdaIZUWvqaYPaw8jd86Ze++558714v3DZubus/Y6a62zzt5r70OfPl1kIz7DL6l9hBu6alHneBCfCD9H8Sou6apFRyErsQLn4wI8jjFc2k2jOsRbuFUk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$\\displaystyle 5 x^{3} + 2 x^{2} + 1$"
      ],
      "text/plain": [
       "   3      2    \n",
       "5⋅x  + 2⋅x  + 1"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr = 1 + 2*x**2 + 5*x**3\n",
    "expr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIQAAAAYCAYAAAA74FWfAAAABHNCSVQICAgIfAhkiAAABHBJREFUaIHt2muoVFUUB/DfNRHNyN5ZBAmVZGUSSRCljvaQDCl6fBCiEoMC7UEUpRBKEEopUUJJRAxRhKBYWFEmFWj0umAkaFDZFJSW0sMiK63bh7UH74xnZq7z9Or84TAze6+9Huess9baaw9ddNFFCebjU+zGTqzFBR3VqDHMxefCnt34ENd2VKNBhrcxWzjBeKzBDpzQSaUawHWYgXMwFo9hLy5shOmL+AkjG9VuEOIY/IuZnVakifgZd/b7fTH6MGcgiyfiP9xfNn4TlmODCEV9eKlRTWvgRNwh3tqvsAe/YaMwZkgLZJ4mbLusBbwLiXfWtaMF8o7CLPwjol9/rMF28QJUxTr8ihFl458JxX/HVu1xiLuSnB/wMhbjhaRfH1ahp8kyV2KTuJnNRkHovijjeqCJcsbjD+zDLyKFlOMScQ8XVGM0VkSH5zLmpoq81IOc9jjENBG6yyPBaHyXdLixifKeEG/N2U3k2R+FdLUaw4QNE8VLtEt2obwV36ri/EvETb6ihsCc9jhENSxIOiwvG1+Xxm8oG+9BPs0tyeC3DD/ivKZqWYqCg3eIeu3pj/V4PmN8YVo/vdLCXhFmahWTOZ13iAeTDk+WjU8QReEWpZ6/LNFnRb+ntd4ZCGfYjluEQ98rIm+19FSPPeV4V/azujLxWJq1aKRwhs0DEJDTWYcYKvSs5N35NHd7+l2MJisdmH6eEUXyNJGKilfNYqsOFGQXlNswpcq6vIHbswSTMEbUEotFGXBNBt9Ric8nWULHpsl1VRQrIqezDrE0yX+jwvwZYkdSwLxE+5bIreWoVPUvaqbCCQuF452Ko0VeXyEe2J8iGmThYOzJi7rgb9E6WK9KSkh8M3c4l9rvdbWQ0zmHuCfJ3qp682ix/Q/3A/EADlUUHXxNFZpW2fO9yAwoDTd70ufwJglqBebiKZFPp4qGSyXs7Pd9jngDD1WsSJ+Tq9C0yp4R9j/7EpwuvG/jAJjktD9C3JdkbsYpNWhniTC8Pa15trWqNYxjhZ5/VZhvlT1DEt+vsyZ7RM7ZmTVZhpz2OsRDSd4mnFSDdobozG3GySK17MW5rVSwQUwX9m3JmGulPeOS3NWVCFYlglqNmZyBOUReaXVcDx5JPHrVPnC6XITSbaIFTbTc+/BqAzoUkVe/PefL1v9MfCm7a9hqe2YnXvOKA0PLCFaLzt90cXbQH9eni9iWEYVoPn3f5cD2a7FG2ac+3IZHxT58gygoy1FIOkzA6+Ks4yoRXgkn7xWngJMSn3rRiD0342G8h2/EEcBZ4mh6ON5U2g9ohz1Xi3v7WiWCYWIL8nHG3CKVt2h9sjtwm8Qe//g6Fa4lsw/vi4i2Q/Tts455iw2Yj+rUo4hG7JmCV/CFOM/YK9LzO7hV6ZlMO+wZJYrJmpFmfhJ2UQPC4DjhfY83yOdQweFmz93iOU+qRThcNDbWNihwpqiaR9ciHCQ4nOwZIU6QVw10wWTRVTsS/yBzJGCcSMdjOqtGF1100UUXgxj/A7KBYFRWbqdzAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left( 1, \\  2 x^{2}, \\  5 x^{3}\\right)$"
      ],
      "text/plain": [
       "⎛      2     3⎞\n",
       "⎝1, 2⋅x , 5⋅x ⎠"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.args"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7.4.1 simplify"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAD8AAAASCAYAAADsbQY3AAAABHNCSVQICAgIfAhkiAAAAmlJREFUWIXt1kuIzVEcB/DPIImFt6GsRM1iQrKwIPKI1DQZLKzmFkrRZEGkRCJkCguPshl2RBQi5ZFHKZrBlInQRDHezQZ5jcU51/y77r1z584MpfnWv3P+v8f3/H7n8TuHXoDhWIHTeILPaMVNLEeffxdap7Abl/FCyOEDGrBFyPE3ShL9VTiEV7iK5yhFFQbjFJairWdj7zK+oh4P8QaDMA1T8TL2X2Q6zUaFP1d4tDARbVjcYyG3IxXHmlWk/4Ac8h2R92BakEz0Cs7iZ4ZTCw7HfmZAlyJhVYa8BHVRt6uwmLsNX3LIT8R2QlpQ6Dn+FtvvGfL1wmRtR9+EvBbVOIKNBY7R06iI7YPOOPVDo7CK87Po66IuFf83xf/jiiuSKV3b9mmsw1bsxY3IeR8jO0NSGx3P59CPFapqM9ZE24voX0TAdF/yLZEn/V0QCnjBqImOTRiWx25nYpBbGFggf3NGgB19dZ0JPqIUi/BIqPZT0op+eZxWY79wZcwR7stceJvoL8enAgPbhyEZssmoxFFhcpK4VyBvEq+Ft0s9HuMYyvM5rBVmuhGjOiBfJhS9V9HnUBEBJpHSPds+Gxoi94hcBhuiQUM+o4iFwqOiUSgkTcLNUNaFAFN6LvnXkXtoNuXmqLwr/xmH6cL2foYxUbYk+p/pQoApxSdfJjzKMtFH+yPnVlqYPPPV2IYfwtVQk4WkWSg6k3BOePvPE7Y8nBQmrhIzIs/fxALswXU8xXuh4M3EOOEGWJnNcauOq+01jI8kHzExC8/caHu7yARSil/5chwQCuM74VHWijtCfh3t5l704n/HL201qxrUQC/OAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle 2 x + 3$"
      ],
      "text/plain": [
       "2⋅x + 3"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr1 = (x+2)**2- (x+1)**2\n",
    "expr1.simplify()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOgAAAAVCAYAAABMpaK/AAAABHNCSVQICAgIfAhkiAAABlBJREFUeJztmmuoVUUUx39XzTQLrTQs/LAhE3uQRCYF+cEeWpIVFVKfDCyRHlJCRpYkERpqSfjBKJNbEChdMbFCLoW3vIX5yMBS6CEq2a0ss6xuvjp9WLM5c+fM7Jm9z97nbu384XLPmbXm8V/zP7Nn1mxoookmTjm8CfwMDGpAXxFQAVpzbrdeDlcj45qe24iKx+nEOaKcusgCX1xTxX0s8C8wWys7H3gAWAt8C3QDvwOdqtE+WUatEJH/RNg4ZMFaoAs4u+4RFY/TjXNEY3RRpLZ1+OIaHPd24DAwUCubiQTrB+AtYCGwUvlVgDagJePAzwBGAxdmrG+DjUMWjEP4za17RMXjdOPcKF0UqW0dvrgGxX0UssK8apTfAEyhdjUZDuxXDd+dbryFwcUhK3YD+4C+ObVXBP6PnNOiDNr2xdUb9xfUgG5M0elcVWeZxXY78CHy6D6KrFIfAQ9pPhH2rYxeHgGrgF+Af4BtwG0ZOLQr211GeYvqp6Lq63hWlU9y9DcOWA0cQDh2qX6mWnynAh8jW6huYCfwFHCmxTckdjF885aWt49zvSibLlxI0nYRWvLGfRtwgnQH6CdUo0uN8hmqvAtZtRYAK4AtwFbNLyJ5IjYih/rNqo83kMk4CUxIyWGMqreLnqvUi6ov2xPoJmVbYrE9qPo6CrxNleMXQIfhu0C1cxBYDiwGvlRlHciWLkZo7GL45i0t7yTO9aKMunDBpW3IX0te+yCEwM6Agcfop/xtv/rtiHAvsNQbqn2OSJ6ICrKy6Jikyt83ykM4tKq696vv8Sq5GntCYLCybzHKLwOOA4eAyy31Rmifr1Nt7Ee2TjH6AeupPXuExg7C562VcN4uznmgrLowkaTtGK3ko6Ug+yhlbPeNXMMSVec9i2078BdwrqeNiOSJ2It9T74P2droCOEwAtle7gUeU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9GcB6CrPCL6uyjt9Cb2vZpKVhrA5Cs4vrchtZ45MFhIPI0bMtlRMWjEZynIE/+4Q572dFb2vbF1Wm3vYlxAvgceYF7G5KZOtWQB4dLkFfSFuG+cysTGsH5a+B54M+MY+xt9Ja2fXE91bTWRBNNNNFEEyXHf9x/JbNChbpiAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left( 2 \\sin{\\left(x \\right)} \\cos{\\left(x \\right)}, \\  \\sin{\\left(2 x \\right)}\\right)$"
      ],
      "text/plain": [
       "(2⋅sin(x)⋅cos(x), sin(2⋅x))"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr2 = 2 * sympy.sin(x) * sympy.cos(x)\n",
    "expr2, sympy.simplify(expr2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAH0AAAAYCAYAAADXufLMAAAABHNCSVQICAgIfAhkiAAAA5NJREFUaIHtml+IDVEcxz/7D9sqrESUVaQWsf6X0Ma2PPBCPCmkPFHaKNYDbyTl35bwcnlR2JAkUiiElJAQ+6D8WWyX/GeX9fA7d41pzr3n3DPnXmU+Nd3mnDnf+X7vnDlz5twLCf8dZcU2kNBDCqgDLvs+Uamm/AjwBqhy1F8CfAdqAmV7gCfAIAfd50BTqKxOnWuMg64rvvKGMck/GegGVpkITgF+RYjmQwlwGzik9tcDr4GRjrrHgaOhsktAi6OuKy55U8BWw/OY5j8JvAL65hK8ALwHKg0N5KIR6AQ2Ah+QTuVKE/A0sL8YSAMDY9B2Jd+8Kcwvumn+acjd3pxNbDRylx80PLkp14EuYH5MejOQMNVAb6ANWBeTdhyY5G0GPgW2TuBHqGyWpq1N/ofAM7LM37YrsblZzC4GzgEdyuQTFUAnOgf4jHSmSTHp9kaeX43IHfUIqMii7YqNN9O81cCowNYK7A2V6UZbm/xbkGs6T2fkNtJDoyZwZchzpBsJvR/YDTxWZYcj2kxAHhXLgVPIFxeHLsANYB8yhC7QBXLE1ptJXh0pzId3MM/fgHjdGVVZhVzw+5rGLarxNqA8UF4BXFN1wZlzDfAC2Kz2xyO9Pzxk2epm2KX0zmv8xoGNN9O8OlLYXXTT/P2Uz1tRlaNV5YWIuunqBKc0wqtV25Vqvxp5lhwIHXcMuOqgG2Q50knHatq6YuPNNG82UthddJv8X4H2zE6w92Zmfu8iGq1FXke+aIyNU58l6jMN1EYct9RRN8gy5Et+EFEXBzbeTPNmY4XFsWCXPw0MjqqoQ3ru6Yi6N6ou19ZgadxWt1SZb0bePwdYns+nt0KQb/408DGqYigSIjwc9VHlV/KyqScf3XpkyH2IvLb4wldmV+qxz1+q2rRFVZYgvfttqLwS+QLiHkZ96cbBv+zNllokS6vugBPqgFGh8ruqfJGm3Uzy+/HGly7IxKgb+2dlBp/eCslKJMeaTEF56IBWZCFiHn8v820Azqr6i8A9ZNgYhizsVwDD8zDkSxf+/JjUlWd7n94KSSPwk+i5GgC9kKn9zYi6qchI0I4sGXYg7/QHyL6ClwtfuneQhQuXyZ4vb4WiH/K6pnvt7GETMhxM9O3II/2R3r2j2EaKzFrkWuZcIOqDLNCf8e3IIwuBb8CQYhspIpXAS2SkMmI2slDv+ieKhOJRiywqjSiujYSEhISEhARf/AYky0Axq45fmAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\left( e^{x} e^{y}, \\  e^{x + y}\\right)$"
      ],
      "text/plain": [
       "⎛ x  y   x + y⎞\n",
       "⎝ℯ ⋅ℯ , ℯ     ⎠"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr3 = sympy.exp(x) * sympy.exp(y)\n",
    "expr3, sympy.simplify(expr3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAM4AAAA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zw3YWC+++YcYaLRwGZfuLxYp6Skn9bHChkqih7A3U/WJJf1pvB5OD5oB4Ee84Ea/v77Gd5WJvcaOKnP2QaQzK9r/BZ/DPHtvvle31IkOGDBkyZMiQIUOGDBkyv/kf8tpRHugk8DEAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\left( \\sin^{2}{\\left(x \\right)} + \\cos^{2}{\\left(x \\right)}, \\  1\\right)$"
      ],
      "text/plain": [
       "⎛   2         2      ⎞\n",
       "⎝sin (x) + cos (x), 1⎠"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr4 = sympy.sin(x)**2 + sympy.cos(x)**2\n",
    "expr4, sympy.trigsimp(expr4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7.4.2 expand"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAG4AAAAWCAYAAAAhKqlXAAAABHNCSVQICAgIfAhkiAAAAzRJREFUaIHt2F2oZlMYB/DfjEli5GMwlCsNTRpGcuGCTDNESpPBhRu2hlIkFyQaOSkhToMyI1eHuxFRyEf5yJhSoxk6NRMZnUyZc4whLpCv4+JZp/O2z37P2e969zvvYP9r9+79vM961v+/n73Wetaixf8S92MnfsZBvI5VQ2XUohbewS0iWefhVUzi5GGSatE7luIvXDNsIv91LG443vEp5g8Nx62Dx/Ee9uPXxGE3HsKyIfDpFctwq5i1vhIafsLH2KiUq0UNd74N5+AiMfIOJ37HLuzBdzgOFycu36b7/YeZUy+4HVtxAB/gGyzHBpyAV3ADppvu+InU6YrM9oUgtSaz/TFd7I+kuFsy4/aCQr6GtWKJKc+Cp4skTuO6GWPZ6d3ksKFkX4Sx9N9jFZ2O4iasE8N8GPiti/2l9Ht2yZ6rdVB4X1Tlf5fsk3gu3a/p1ni1mOL24KgO+6gQ8nxFm2cwhXOz6M6i0N+I64ZNKe5oyZ6jdSEUBqPh3hR383xOY8mpSM8PpOdt5o7QLWIPt1YM6ZlraQa5QjOi78GIELk9xfwcp1b4jqmvtQ4KzSduCcZT3CvnczxTVDQTuDM1eBtHV/hOd7lGMggWmhE9WeLylljkq9CL1jooNJ+4J1PMN+s4P2pW+A4c2yAR4kV1S3rVNZbRx3Jciy9EVXlhF79crRM98M/VcFdqu1fpUGNJlwYHO+434peMTufDUzixZLsA6/GCeCmd+CyjjymxJ9qFL/Gi6uO4XK2D1nAHnhZr8Do19sY3isrmgMj21h47zEVhMAs7sRGfxikle9NaC81ouDvFGcdpdRpcLTay42Ix34s/sLJPInVQGFziplLskzpsg9Ba6F/DfSnGbnM/tEpcIqaJr3FGsl2fgrzWB5G6KOSLXimq2TIWm92A7+iwD0prob/EPZjaf2qBg/qZNW413hBnY1eIqQNeTkHW41JRXh+JuEqc3HyEfTgkipPLcJaoNG9Lvkeq1pvxsNhbbheFSRkTOoqcFULYjzi/wvly8RV80izPOSjkf62r8KwoAL7HnyIxO8XWZObrHbTWQr6GEQtXph9m8mrRokWLFi3+NfgHumgQb8udVfsAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x^{2} + 3 x + 2$"
      ],
      "text/plain": [
       " 2          \n",
       "x  + 3⋅x + 2"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr5 = (x+1) * (x+2)\n",
    "sympy.expand(expr5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAAXCAYAAAAC05jwAAAABHNCSVQICAgIfAhkiAAAB75JREFUeJztnWuoFVUUx3++SrNQQcPEZCAxLcii0oKMAqmQXvSQioghU8IepFKkKfUlK8se9LCHxc0vaWlFQogU3ltK5gMFsz4lV0tvZqkVZddHtw9rD86Zs2dmn5m954ze+YOce/bae/Z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+B3KhYgSypDyM3MFYBt2nq3oHMJP9CXkzaDjxB/WFcI5yPy5swbPLCBD7ZuFymXI/Cpg9dcAby88ZVrhhzarbqIOlwpUiUTZ80fIbMLi41qPsQ8aP5QPWcBfZUKww2Y5bkozIhzWZbvDiZ0R19WFSuGPujL3K6vdKCQjZQNn2SEBxOvWZQtx8y61geI78BmW0MjZGXGbZiluajMiHJZpu8OJnRHX1YRK407I8rkde4y/IfsJRNnzBGAI8jV706kd8JMXkRbQzwFLJkPhlhI2Ynmo/CNle8yIbu6EPXuXKi+eOEQvDjTweQA6VhydUrdBNUvMiPyocVKlSoUKFChQoVKlSoUKFChQoVKuTD/0LGzL56VPdIAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left( \\sin{\\left(x + y \\right)}, \\  \\sin{\\left(x \\right)} \\cos{\\left(y \\right)} + \\sin{\\left(y \\right)} \\cos{\\left(x \\right)}\\right)$"
      ],
      "text/plain": [
       "(sin(x + y), sin(x)⋅cos(y) + sin(y)⋅cos(x))"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr6 = sympy.sin(x+y)\n",
    "expr6.expand(), expr6.expand(trig=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADIAAAAYCAYAAAC4CK7hAAAABHNCSVQICAgIfAhkiAAAAhNJREFUWIXt1kuIjlEcx/HPXNQ0bNxKrgtTJLk2zQhZmGbDxliSTEo2dhKjlIVsZiGXxELUlA1lIwsURRYKQ7lNyZBoTEJGuVuc845nZt5nRp55xpT3V+/i/M95vr/3f/qf/zmU1Kv9uJQD9yjO5sBN1QW05sAdj3E5cFP1EhtH0rCYyjN+PxlT8QNX8AntqM/InY6fmJOI7cU9fMQbnERVRp9eNUbD21iFubiITlRm4K5Fj98bXYZ9WI5ZaBAqYVcGjz7aic8RXtACIbmaDNw9uDnEmhM4VRhkLa3FQmfpTMR6hoG9CHcT4xk4hPt4K5RXM14UFqSZrRdKpBtf0IEWVBQxvNMvtgTv8TQDd2EikYm4hSnYgZWoFSqhPeX/q8AZoTQ6cAwH8TjGTifWVuMbdidiZbiOwxm4Y/EddXG8Ce8iu6DN8bvZaYkciQsO6HtYx+BGnJsXY/X4igfRtAZteIYJGbjLYiLVcbxG2LB10WM7XhVJrld1Qhs9n5Lk1mjYHMfb8AhNeC603nNCCWTlPkzMlwm3/Ad0CWelFVf1W1RQGzYIJfCkiOF8oca3CD38T5UXN1Vdws4M9WsYJdyiqoqwa8MBGwHuACVvTpg0zPy8uIOqXdi9ppT5FQb2+3/J7aPkYW8UnuSVuCw80MoxDUuFVjnzLzzy4g6qWuHJ8Vq4I7qFZ8FxrB6F3JJKKul/0y8kqJ8SZXM1lgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle e^{b} e^{i a}$"
      ],
      "text/plain": [
       " b  ⅈ⋅a\n",
       "ℯ ⋅ℯ   "
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr7 = sympy.exp(sympy.I*a+b)\n",
    "expr7.expand()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAlYAAAAaCAYAAAB1oBIhAAAABHNCSVQICAgIfAhkiAAADmJJREFUeJztnXuwXdMdxz9ERIjxrFejuSUS1UbiUY+qKVONR/VFx1SnY25VMIppUZqqVh90GpRSo03LqApKUkRVxbQoSkkIaauYaphyKwkSQYLE6R+/teaus/Zae+3XOWfve9d35sy9Z71/v71+373Wbz0OREREREREREREDFlsBrwE7GiEnQfclZJnNnBaJxsVwOWqDWXgkjuEXssdERGRhM+W68xjVXAYRB6LiKglLgB+bYXdDlyYkmdX4BVgk041KoDNgDEly3DJHUKv5Y6IiEjCZ8t15rEqOAwij0V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zekfYLyD6blYiX5B/Ibx/am5qz8qOGy2ay8hr0ntt6ZYO+sUUnuK1qXoPucFtERBDTkU5sX8DWlPpOUeVVvQetbqhSbyGdDRedRgxtNJnbhosNdvt9MFz0GtFjbICcwLmtgfWNRmbDsysoq+6oSm8hnQ0nnUYMbTSV24aTDXbzfeCNH4obHiN6izXIWvYoZP3cvoOkzvXthOzlmIH/Dq+hgqr0FtLZcNJpxNBGU7ltONlgN98Hw0mvERERERERERERERERERERERERERERERERERERERERERERERERleH/u1cwIxl879gAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle i e^{\\operatorname{re}{\\left(b\\right)}} e^{- \\operatorname{im}{\\left(a\\right)}} \\sin{\\left(\\operatorname{re}{\\left(a\\right)} + \\operatorname{im}{\\left(b\\right)} \\right)} + e^{\\operatorname{re}{\\left(b\\right)}} e^{- \\operatorname{im}{\\left(a\\right)}} \\cos{\\left(\\operatorname{re}{\\left(a\\right)} + \\operatorname{im}{\\left(b\\right)} \\right)}$"
      ],
      "text/plain": [
       "   re(b)  -im(a)                       re(b)  -im(a)                   \n",
       "ⅈ⋅ℯ     ⋅ℯ      ⋅sin(re(a) + im(b)) + ℯ     ⋅ℯ      ⋅cos(re(a) + im(b))"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr7.expand(complex=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADQAAAAVCAYAAAAJiM14AAAABHNCSVQICAgIfAhkiAAAAhJJREFUWIXt1jFsTVEYB/Df06RaldRiIFhUw6IR0kTCZjKKpRs6qsWGyUIjzBJTY6EJIbHIm0kUsUiYCAMVHZgUrT7DOU+f13vvu/fdW4mk/+Tl3Xu+//n+57v/nO8c1lAaN/EZAyVy7EcD45WsqAWNHL9NLfwDWMLZCrTvYRYbWwdrJZM24v/FDM4kvsfnOkaxBfMltUcxgwu4VDLXHzRdyINhwZ0bVYnjNd6jpzmwro1QFxZ4rG28hqkYm+xS/FTMM50S70b7NnbgSJroCH7hlZaqcS0mbP+6RRx6jkXpzaCoNqGQBq5mCU9F0on4fj6+T1vpaN6CBoRiXnbgFdGGwRh/mpV0m7Bh32EiTniI3gRu3oKGI6/egVdEu4l5fOq0gMuWF/sYG1J4eQs6aPlLV6XdxAfBfSTbCHMtz+P4lmMhWWi26L4c3KLa/TocAWNCe50VvtL1DG5eh7ZG3qMOvCLaBEOW8CaNcBQ/hc27WejzC9idws9bUE247sxlcIpqw56ofzcpeEiw961wksPxOOF+SsIibftO5A5VpA0nI2eiPTCCr4LVO9tiz+KkwwkJixQ0FrmnK9KGW0JD2N46OCS0vS/YmzCpeXg9SYgVKag36sxUpD0oNIMsB1cd54QF7qsg1xnZ7v0T9AmXyQcl8/Tjo7Av/0LPSu6qYhEvsF642y10mWcXfuCKsP/W8N/gNzNatPcD7MAgAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle x \\Gamma\\left(x\\right)$"
      ],
      "text/plain": [
       "x⋅Γ(x)"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.expand(sympy.gamma(x+1), func=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7.4.3 factorization"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIIAAAAVCAYAAACKYDYGAAAABHNCSVQICAgIfAhkiAAAAyNJREFUaIHt2U+oVFUcB/CPGuXTwBatwtyo2SqNQhQKJhAXbhRx427IdtmmnYLgzpCCoIXg6iVBCUJBG3Ej+Af8EyGIGoTwhOqJLgwDn5E2Ls55er3euXPufXfuk3G+MMzcc77n3N/3y+/8HcYYowRHcAtL5zuQBvEeetiVwB1F/VTzwPv4H58PM6KGsAPf4DTuCiK/K+H/iGm8WsIZZf2keQBO4G9MzC3GVnBJEP8PrhlsxPrI2VvCGWX9pHngLWE0HJ57jK3gI6zGAnSkGXENN7CooG4+9HeFuDs12tbRT4EHC3OEj2OnRwsan4gv2p4rX4DJWPdFQhBN4iR+j+9OxQ9YgU0FdWX6ef48qKOfcg/AL3igeJO0Fg9x1dOj6asYyHzPIh1pI2JT5H1ZUFemn+F40FV/RsiiI31GKPPAUsGEyyUdTMYOuvF5b3w+6tnZpW10pBmxLPIu5MpT9NO8B13tJ0I/DxDWx54w/fXDcsxgCrsj/zheTo12iOhIN2IGN3NlKfpp3oOu9hOBYg/ARk8yuwwHIq+Hs1iS+OKpTLuUT6qgWXQqtPtTGP1ZpOqnPQ8mE/uleiI85cFLmYqZ+L14QAe3M7934V7ii6/jfiIX/qrArYoJT/TOIlU/9T34Gq/lytZhK74VEiWLS4n91kGRB+ANIaPOlDTeKRyvpiP3UNPRzQEdaSNioaDheq48RT/Ne9DV/tLwjAfZzc20kOlr+jTeImTtFbyD3/AJ3q4a8TxjjXDcy4+2QfoZYQ+yidDDKbyOVbmGH+AY/sBmwbB9wtLS9t3BXLEhfp/MlZfp58Xw4DF2CoZ8milbK1y5TmNljn8x8j9sLsZK2CZsqCaFnXtPmO5my4rOyd8Lm6Q3C+qK9DNcD7rqLw119FPuAcIR6CbOx+dV8fmOMBXmMXsxca5K9A1iv/Jd91SOv0zYIP3Up7+8fobvQVf9RNivmn4Ge/AYe2In79YI7HnHZwaP3lHWT5oHCMenG/h52BG1jAnhSHpsAG9U9VPiQdE/cA/wK14R7t7/G2po7WE1/sVBYb3vh1HVT7oHY4wxxguNRzasRTlC0SJBAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left(x - 1\\right) \\left(x + 1\\right)$"
      ],
      "text/plain": [
       "(x - 1)⋅(x + 1)"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.factor(x**2-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAE4AAAAXCAYAAAClK3kiAAAABHNCSVQICAgIfAhkiAAABH1JREFUWIXt2FmIlmUUB/BfbmkaY5mM0vYFNRJkZvumaUl044U3UV4IGhi0UhBREUUXrd5kG1mCKZGhZSAWGYVltJhLYWUquZQ2uZRbYuUyXZznw9f3e75xzBnmZv7w8cyc7Tnvec5zznlfunDcqKAFMzrRh5nYir4dvM8d4lknHUXukiR3W2tCFZ0buEtxCPe3o81GHMTUEv118azD2mBjHprRr55ARecGbiF2ok872pwsnml0ib4C+9CjDTYuTzYeridQ0XmBaxLZNq2d7X6A7eheoJ2If/H1MdhZhY1FO93aqHgzPsMucVIr8VByoowTcC9+xN/YjBfRgA3pV8akpPd2Kz6Mx5tYgz3YgW8wsY58A67HfHFdqxiKnliGi/AO/sBekfUXZGzNxlkYk9uoIp9xTyb6NryC5/B9oi1KThTxcuJtFrVlSnrYJYm2IbP3UhxQvymcjP34EtPxVFq3p70ezOiMT7yxJfrtib5ABGsunsXiRN+K/iWdMYk3JedcRW3grkq0XzCoQO8hTrJ890ck2urS5r1ExraoDVxfEbSVOacS+pX2r2KwyL6fMrw5+Au9S/RpyY/tGF7izZSvZw2JviTnXEVt4F5LtMkZ+SZxBdYVaNVuNSEjf4184JoSfWHOqTZgtciSInqLgM7JyC9VfxS5IvHeyvD24ffqP0ercRen9ZMMbw024RyHs6t6gp9n5L8SmVXGgLTuaMWPU/BosrFDHFhL+jUlP4q4UWTpvBK9p6hxG0V2lVENTDlL4U+cVv3naO24Ia3NdfjNomg2iFGiKr8lI3tQFOEy9rXiLFwosrFRXJXZ4iH2i0ObgO9KOuNE51xQog8VZWO+/CGendaNGV6fgq9HDdyutA7Czxn+4JLc7rQ2OvIKE618gGgQRVSv2QB5zBIZPVo0oyKeSOvS0j5jxS3ZVZKv3qANdfYal9Zy2eiWfFhfJLSGFWkdleGdizOSsZ0l+Wsz8lfKH1Sz6NhDMrwzRcYtUhu0/g6PIssK9JHiEMrXlHiFglMzvMGi465VG7ghYlz6NqOXbQ5XJ9p6DCzQu+O9xHukQL/O4a7aUKD3wqfyzYEYCVrEYRQxMNHXOHLsGYAPE2+/I6/5C6IsNGb2WZJ01jly9OmHj5LeTRm9iUnvrgyv7hz3TKJvwUti5lmZaItFUIp4NfE24Xkx+6x2eI4rX2G4NencmeF9nHjL096zxCgxJz1oub79mvwqo4eoUcvF+LJWzKRTk6+HcE9Gj+iyB8QNqEFF/VeuW0Sn3CPeBn4QmZYr6N1wX3LuH/wmAt6Q9HPp3kt0tNxr0EDRAbcl/S9EQxie/J1ekL0s0XIfCoYl3jScjndFTd4tsndURkfye5+4YZ2C89SfkYhXuBa1Q+mxoPqWc85x2Cjj7mRzRDvazGKQ2qZzkhgNWsR7bw69xRgw/zj2XqVOAf+f6CNuzNx2tFkXT4sAvJH+niHqTgveF92pHkbiMR3/IbOtOB+PizLW4bhBfM5pFjVurxhTHlD7QaALXehCFzoS/wHExzeGBzosSgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\log{\\left(\\frac{a}{b} \\right)}$"
      ],
      "text/plain": [
       "   ⎛a⎞\n",
       "log⎜─⎟\n",
       "   ⎝b⎠"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.logcombine(sympy.log(a) - sympy.log(b), force=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7.4.4 merge similar items"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWYAAAAWCAYAAADzczZjAAAABHNCSVQICAgIfAhkiAAABnpJREFUeJztnHuIFVUcxz++MmoFzWyzB1ZYSPgMof5ICitSI6LHP/ZHndIwMiSokKRoCUR7iJWkIB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\n",
      "text/latex": [
       "$\\displaystyle a^{3} x^{3} + 3 a^{2} x^{2} + 3 a x + b^{2} x^{2} + 2 b x + 2$"
      ],
      "text/plain": [
       " 3  3      2  2            2  2            \n",
       "a ⋅x  + 3⋅a ⋅x  + 3⋅a⋅x + b ⋅x  + 2⋅b⋅x + 2"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr8 = ((1+a*x)**3 + (1+b*x)**2).expand()\n",
    "expr8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWMAAAAYCAYAAAAvUJxXAAAABHNCSVQICAgIfAhkiAAAB9lJREFUeJztnHuIVUUcxz8+8lFGlpVphRUqFZmZ0oOSyrLUiOjxTxE5plGUSfTACqIlkrUyehdYxrYQJWgWFpXZg3LLUlwfkCUVW1Fqq6m9rFbb/vjNZe8e59x7ZuY87o35wOXunjnzO7+Z3/eemTOPA4FAIBCoe24G1gO/6s+nwMU1bDcP7gZWIX63A0uBkwr1KJ568tVEvfsfCKTGpcAUYAQwEpgDdAAn16jdPHgHmIbcFEYBS4AtwCFFOhVDPflqot79DwQy5RfghjqymzUDgL3AJTHpzcDPwAG5eRRPNV+z5iagE7jOMb/J/7Ha5nQ/1wqjlvRRKyTVSb3H3plewFXAP0gvpdbt5sUQRBBnGdLGAf8CtxnSHgTeA34AdiONUStwHzAoE08r+5oHz+vrj3bMH+f/EmAzcrOuJ+L0UYQ20mYQMAOJzddIOXYBK5CbZ88KeW10UnTsfcppzSjgd2APsAMZXqhlu3mzEPmh9DKkLQN2Av0Naf8AK4EXgLnAk8j4aCfwI3B0zr7mQSsi1t6O+eP8Pw2pt3vcXSuEOH0UoY20uRHx9yfgJaARKc9OfXwR0CMmr41Oio69Tzmt6QMMR1rxRmAb6UyipGVXIYU+NwWfbHkYaZWHG9JGIr2e+TF5+8Ucn4OU5xlv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B/yFuSt+P3Inv9nywuVchYz7bta2nvWwZYPC/xEjbd+HajsrHPO36vyHlh3LOn7VULjX8wyd9/aY9Ed1us9a855IDL9xzK/IT0c++shTG4p0Ht9v1XY2AIdXOM9VJ7UQe0hYzqPpGr+KMhDZ6dMJnOHoxBRkbeAGZHJhI9IqH+9ozwaFX0Vm4XsPZIyuvdqJMWxFynSw/j/r+CVB4V7Pz+q8cwxpQ5De4ybcN4MAnKCvsdgxvyI/HfnoI09tKPxvUrO1jVa6NyAmXHVSdOzBopyH6RM3IeMyJQYhL2PpRITjsrTsbKSSvkUqDOBKbfM1B3u2KNwrMkvfF2k7pk0Kx2Oe+e5J18L+lrLjWcYvKQr3ev5c5/2W7u9gGICsmd0LTPJzj2n6GjMd8yvy1VGcPmpJGwq/m9S9Ov9qkr3cyVUnRcYeEpaz1IK0I+vzJiA7W5YjopkMfIB08b9AHnVsGA28gezFnog8noEIbTUyDjMeWZZTa2Tt+2Jk581FyJ71ciYhO8o+Qh6ttiPjfecg60S3ANeXnZ9V/PKgNzIW2IpMZq1FblB9kQ0SQ5HHO1PPzoYLkR/r6552bHHVUZw+/i/amIoMkexFyj7LcE4bXRNkPjopKvZgX05AWtBmJHi/AZ8gA/tjkLv6AksnhiPC2IH51ZcXaLu2mx5sUdi3ann43kdfw7St8yTgaURw25DJil3IbqkGzK1r2vGzReHWeyjtGpsPHIlsRCi9x/odB3smDkImb3yeZhT56ihOH7WkDYV7j7GB6isVPiw731UnRcW+RAN25QwUxN1IMKKL1wPpcgtSz+OLdsSSoA9/6jX2gZzphyzDWVq0I/9j+iNrbxcV7YgDQR9+1FXsi3pVYkDYg6wN7YuMH3ZUPj3gwAhko8BDyGsL64mgDz/qOfaBQCAQCAQCgUAgEAgEAkXxH/pG278ODlxUAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle a^{3} x^{3} + x^{2} \\left(3 a^{2} + b^{2}\\right) + x \\left(3 a + 2 b\\right) + 2$"
      ],
      "text/plain": [
       " 3  3    2 ⎛   2    2⎞                    \n",
       "a ⋅x  + x ⋅⎝3⋅a  + b ⎠ + x⋅(3⋅a + 2⋅b) + 2"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr8.collect(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7.4.5 fraction"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHMAAAAfCAYAAADUdfLHAAAABHNCSVQICAgIfAhkiAAAAkdJREFUaIHt2r9rFEEYxvGPYiNGkIBgFwsrEQyWQuRIlUa0ULAQzB9gaWOwsBchpgjYbcBKFARRG4uAIoKFioWFBIJFRIQgouDvWEwClzW57OV2Zy6b/cIUO+zs+zy8O/Pu7iwNDSVxAvexgCWcSSsnGpX43lnGRXpgD17jYmIdsam97+00M9upzcxsKJEmmTWiSWaNaJIZGBdqVyutjN5oklkjdiWOP4BDbccHMYxFvE8hKBK19N0Slrd8yyLrGBd3mW2pwHfqmTmLHYk1pGBWBN/z1r5j1mu3qhZUAfO685ilELkZ8jNzDt+7GL9QopZYTGJfrm8YpzAjJLudVxE09RXd3OmxWjeM21zNTO1xVSurZm7Hukef+W7eM2vEVkzmZbzAF3wS9gWPJFVUPYX2P/slmRmuFjy3hWkcxyh+4zEGK9BVNZlivqPvf57FDwy19d3AO+zfYGymeDLzDOAPTm5yfK/E9h1lZt7BG1xZPr6EcxgTlsOq2Cv4WKwwRidS+f6PMr8ALWECD4T31QlhGZwrMcZaTArvgs8rjrMeqXxH4ZlQx8Y6nDOBr23tF37m+kYKxLqGD1Z/tE5FLN/Rfq8ZxTf8xbEO5w0KCVhpdzGV69u9Qazr+IjDvUkuhZi+oyTzKD7jAu7hURdjM909CEzpn0TG9E2HZJZVM4fwUFj2ZvBSqGMjeFJSjBWmcR6nhYeeA8v9K8tUTGL5jrb/OYi3uJnrv42nBa+RKX6Hrvdtsuj4sojpu2WL7+g0NDQ0NDT0E/8A+/0KYhWpxaIAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle - \\frac{1}{x + 2} + \\frac{1}{x + 1}$"
      ],
      "text/plain": [
       "    1       1  \n",
       "- ───── + ─────\n",
       "  x + 2   x + 1"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.apart(1 / (x**2 + 3*x + 2), x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAF0AAAAgCAYAAABwzXTcAAAABHNCSVQICAgIfAhkiAAAAqRJREFUaIHt2j+IFFccwPGPMSmMF0SJICn0QG3E02sCFirmGk2RJihYCCFg51XhGi+BWKQJQdAr/FMEVks5UAhBTJ2IIoKiIJhcI5x/YnIkIU3in7N4s8u72dnZuXDZGfB9Ydh5v/d25/t+O/Pe28eSSPRhN77DQ8xjf706/4036hZYJCtxG+N1i7yupDs9UZ2U9BpISa+BlPQaSEmvgTfrFlgkQ9gUlYcxijk8qEPodWCPsFTMH636lBKJRKIxLMte52u1SCQGzWo8wca6RXJM47MedU11pty7wzc49/+7LKDKHvk2YS2+qqCuDmc4ihv4C0+FPmzNtSnzBm/jD+xaIqkWjlVo9yG+wsfKt2tv4kguVpczXMGnQqJHcBGPsSbXrsi7wwHhW1mWi/2DDVHsJH7G2j5SLdU70KYs6V/ip1ysCc5thvACH+XiXd7x3stO4VuJVzLTuIMvsvIEDmKf8EgNkut4HyuiWJOc3xHyOZeLd3nHey/DwrgaM49JfI+Z7HwsOx80D/EW3ouuP6w5zidwC9dy8SLvDldwtscHXsVz4W7pxST+jo5n+DcX6zf2lg0vm7P6eLJqgjNhMn9k4WZcT+/4Tv9NWH7lGcN24dH5teTCZ3AhKn+NWUxFsdmS9/ejPUHFQ0QTnI/jED7ALwX1Rd4dJnA3F9surA4+wSVc7iMQ07K0E+lh3Qmo23lK+I2wpaRNkXeHEWH2fTcrb8gaf56Vt+Gl6suzlmodGBL2xEeFpE9k5+tz7c7j24Y4wylhjT6GddExVMF7AVeF/5SswT3d4+UF/FhRqqVaB/bov0e+QujgjoY4K/BtH/H7y7w77MV9LK944UExjh961DXVmR7eedEZ4YfGI/w5AKmqjOI0fi+oa6oz5d6JRCKx1LwC7NPSV/YvPHwAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\frac{1}{\\left(x + 1\\right) \\left(x + 2\\right)}$"
      ],
      "text/plain": [
       "       1       \n",
       "───────────────\n",
       "(x + 1)⋅(x + 2)"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.together(1/(x+1) - 1/(x+2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACUAAAAfCAYAAABgfwTIAAAABHNCSVQICAgIfAhkiAAAAT5JREFUWIXt1j8vBEEYgPEf0VFJ1KfQ8wXI5SpKCYnPIEqVKDQKUVHRnfYiGsEHIFpEoUAjoSDR0PiTnGJXMrk4xt3KIvskk52Z7PvOk5nN7Ms/ZATbuEEdE1kk7WwzvhsnmMnA5Uf4NTv1IxRSsRRSsXS1Gd+DgWDcjyHc46rN3C1TllwFja2al1BB7nSkz3quFgV/hKj6K6sbvYqFiPei6q9QahJPKAVzKzhH33cMP2EP89iKldrEaRoEs5jCKO4ykooi/PfVMYcdXKb9StrPnUO8SnaoGXN4DNoLnhvmhr9Yp+mH3lglVDAoOdbbTxKuoRaMl3CN1WDu+guppoRSg5IPcBrjWMRYk7j7tL3zkI4vWhX5SKqEXSxjA0c4lhzBfhYLpUTXX704w3pDghoOIherirunyor6qyAH3gBSW0s1V+uiwAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{1}{x + 1}$"
      ],
      "text/plain": [
       "  1  \n",
       "─────\n",
       "x + 1"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.cancel(y / (x*y + y))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7.4.6 replace"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2*y\n",
      "3.00000000000000\n"
     ]
    }
   ],
   "source": [
    "print((x+y).subs(x,y))\n",
    "print((x*y + 2*x).subs({x:1.25, y:0.4}))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7.4.7 numerical calculation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4.14159265358979\n",
      "[ 0.          0.84147098  0.90929743  0.14112001 -0.7568025  -0.95892427\n",
      " -0.2794155   0.6569866   0.98935825  0.41211849]\n"
     ]
    }
   ],
   "source": [
    "print(sympy.N(1+sympy.pi))\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "f = sympy.lambdify(x, sympy.sin(x), \"numpy\")\n",
    "a = np.arange(10) \n",
    "print(f(a))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.5 calculus\n",
    "\n",
    "### 7.5.1 derivative"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGMAAAAWCAYAAADU1CLnAAAABHNCSVQICAgIfAhkiAAAAwxJREFUaIHt2E2IHEUUwPHf6iIYVIIXDSgejOD3ag6CoGaMngRRJBdBpUWPogdPLkoGLxpNcFXQIAgjCiIIEUT8BMEPFOIhF8XPZQ7CRgIaZTURP9bDq2XH3u7e3u4eV3T+UDBV9erVe/Pq1UczYcI6uA8H8BMO41VcuKEW/Y95E7eLAFyE/TiEUzfSqAnBSfgD12+0IV1zXK6+E0/ifbEtLOGFivHDJFNUDnVs6zInC7u/H5P+9XCrFX/vbKtsOle/HzNYxLc4t4aOHzFX0L7YzrRS5nAQH49Jf13OFAt3UWRr51yNczCFnnqZMRyHISU8igVsbTg+Ez71WtoxhXfwTbKpk8zIb1Pv4qukfFy8lfTflGufwiD1PVwwbi9uwzX4eoz21eFu7BAXi58r5Jr6uoqeepmxgFswi3tEdh1fMWZGHMCf5eT2pvmeKRjzBL7D+XUMryDTPjPOw1E8lup95ZnRxNdCepof4PPYXjFukOSyVJ9N9ZesztanxGViB04fKU326Uy7YEzjE3yBE1NbX/U2NVDf11J61g7GLvEnnYZN4i2wD3/iF7EyijhDrK4h7krzvIETCmTLbmv9uo6MkGkXjAfFSr98pK2vOhjr8bWUnrWDUcaeNHZ/hcxDVv7YD0Uwu2SoPJBFZbCGvsvwOx7JtfetfYDX8jV/te2KfbgXV1XIHB75fYfIpC6Zw+Zc2yW4Ac9ZfQs8WKFrGs/jSzzQwJbWvvY0z4xT0thjJf03i61sIck93WCOJmSabVOb1c+w/Jurtq/jyozlPXW+oO86sTI/FefNeyLFH8fnY7KnLb/i2ZK+bbgUH4iD/aORvs587anOjAsUf6w7y8pbZTbXd4VI0XlsSW07k+wr6zGuIZluHn2j9BWfGa19vVEcZANx4i+JV+Zy256cEcfwurh+7sbL4uawhNf8/cYwgyMiXc/OzXsgjbmyjpEtyPwzwejE12XFZWU4IrsdL4p0O4LfxEH1tngpT43IbhUfDn/AxQXzXpv0j/t7U2b8wfi3+DphwoQJE/7D/AURwxDV0TXezwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle 15 x^{2} + 4 x$"
      ],
      "text/plain": [
       "    2      \n",
       "15⋅x  + 4⋅x"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr = 1 + 2*x**2 + 5*x**3\n",
    "expr.diff(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAGgAAAAVCAYAAACqoKu+AAAABHNCSVQICAgIfAhkiAAAA9dJREFUaIHt2H+IVFUUwPHPqpibUdHvIuqPVIqiHxRBkDnV2kIRRdkfQeSU/RFkP+gHlRAtERjhH0V/JAWxRVGCsoUVsUEGKlQsJSy4QWVTUEpGWUFbrWl/3PuY53PezJs3s2XsfOHxZu4959zzzn33vHsPPWYEr+AHzP+vHfmfciH2Y0UzoWNxB0bwJSbxC7ZExVk5ehdhH+5v0LcMz2Ezfo1OvNrC2VqUa3TtaqF7KFA2jiPYiSPyDN8pBOF7vIbVeAl7Yvt69DXQG40y/Q36tkXd3zCh+ATtwVCD68EWuocCZeN4cexflWf4Clzr4Bk+Cd9G5RszfYuE1fNCjs3LsTA6VFF8gmotZKabquBrpYRumTgmTOAbzE4a0kY+wEYh4Gl2YW38nXX4diH463IG3IQvolPTxWi0f0OmvQ/Dse+paRw/S5k4JryB0zCQNOTlwyxT8b430z6Av/FRQTtFOQy3CMv9XmElzs6RfUgIxpMZmTVYjhfxSJf9K0teHBO2xvvSdozOwbjwJg6m2ufHgcYL2qnobJOwA0tydIajTDX+XxX/r1P8JUxTVT7F5ZEXxzRHxf5P2jG8Jiq9k2lfFNtHC9qpKDZBjwt5/EQcjnOE1LAPv+O8BjqnCrulGlbGcd7D3IK+Zanq/gTlxTHLpDZ2q/dEoxM4JtN3ifpbWoSKYhOUR/KAIzn9q9VX21ZhcotQ03jF5l3DJXxvFscs30mlwDlNBO/Cs9iOK/FTpn8y3ue142kHrMUDuCynf3fq9wphtRXhGRydaTsf1+FlB+8otxW0m9Aqjln61WOby33CjI/jhByZU6LMloKOVnS2go6M+n806LtZSIE7o8zzJcdIqOpOiisSxzSzhOf4qpnQw9HoZziuiVyfUN7Z3UQmTUVnEzQY9bdn2q/GX0IQjhfSyBTOLDkO3ZmgonFMc1bU2ZAn8FgUGNM6VxJOxfuxoIBsResJOjtn3NPVz1Ppk/alQirbgZNj27Io92YBn/Ko6myC2o1jwm1Rb2XSkP4GLccTwrlms/Bhy1Jz4Edyg3AqHhTqTlmujxfhJE3YXCQ2fnRg+eYm4cyyCV8LJaIzcI3wrXtX2CwQdnNvC3WupUJ6I7w0Y8I3ZHF8ln+TMnFMuCrqvdXI8JDWO5gPMzpzhS3hxznOtrJZy8gvwev4XKhdTQkp9H3cql7DWhDH/RnnNhh3INove4CuKr+ChrQfR8IZaFJnK78hj8ZBL+i24RnG3UIcF3fb8DyhwLex24ZnEP1C9Xt9tiOvvtUOe/GpUD8bU6839SjOQvyJp4XU3qNHj67wD4gBQa8eMP3CAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle 2 \\left(15 x + 2\\right)$"
      ],
      "text/plain": [
       "2⋅(15⋅x + 2)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr.diff(x,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAAaCAYAAAC+TYsuAAAABHNCSVQICAgIfAhkiAAACNdJREFUeJztnWmMFEUUgD8Q1BUVECSCR8aIKGq8L1C87zuK5w8dRYhRPPAGNZqoqAjeggrqQoyKgve5ioJHRJSI4vHDuIIGVkVlPRFZHH+86kxvb3VPd3X17PRSXzKZnTpeVb/3eqpeVfUsOBwOh8ORkm7A5inqjwY+An4HlgEvAjtY6FfWsh0Oh6PW2VaX2NmS8M7AGOCHFDIOACYCg4GDgBbgTWCjtJ3LWLbD4XDUOmsDZ2UlfDTy5WqT9YHVwLGW5WYt2ybTgJ+Q6Koa7AaUgGFVaq8jUUB0V29ZrvOBfFKLdrsR2Nl2w72AN2wLBfoiF7RPzmTbYnfgP+DSKrf7LNCE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J3FtV8DuAJB3H0hDEh/wqOV7F8xtZ9tuIwlEB/2RC1xO24cKoPxgwdwQgZOAcyzKi8sQJWce4U8imzAIUdBPSKi2FDmiNVRT9jRkCewPZFPlC2T2ENwEOg/5oaZGZAbwK/JbRFeif9R9bUSHH6rPaXWaRFfdkQ2kNFFaEfMBAGSWcwcyS/sXWWt9HtjbV6ZaOolruwJ2B4C8+0Ba4vhAkFq8dyGd7WzbbSZto5ZUbIqsy1WbF5ARf492aLsajEYMn2Zj2yOJri7EToRW6+TBf5wP5JNatVsv4C0LfWrDzehHtqzwNkTuq2Kb1WZd5ERCpVNWlUiiqzpk1jQjZZu1Tl78x/lAPqlVu40mo5/A74r8gJGt/zCmYwvk6NdkZJ3vc9I/UFbr7If8fEDSfyphqquByNPRhYTt5YG8+o/zgXxSa3bbCokQMqNXROM28H6UaTmyydMvuvgajdNVW9Y0naxp19tRyMpuu1mS43A4HA6Hw+FwOBwOh8PhcDgcDocjB/wPDR4U6k0hDbIAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle x \\left(x^{2} y^{2} \\cos{\\left(x y \\right)} + 6 x y \\sin{\\left(x y \\right)} - 6 \\cos{\\left(x y \\right)}\\right)$"
      ],
      "text/plain": [
       "  ⎛ 2  2                                       ⎞\n",
       "x⋅⎝x ⋅y ⋅cos(x⋅y) + 6⋅x⋅y⋅sin(x⋅y) - 6⋅cos(x⋅y)⎠"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.sin(x*y).diff(x,2,y,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEwAAAAhCAYAAABz/U2vAAAABHNCSVQICAgIfAhkiAAABBJJREFUaIHt2FuIVWUUB/Df2E2zsHsklQccNF8cTJMeMilMxcqiiIgejISIsB4iuhhR9FA+dJMeQq2wINJQKooKrbQSM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pJybk5wpRQzV5l8dwn2XJP7bRKswuknFWo2hQu9XmpAxTNx9V/THVMv8a7qoKnfiF/X1VP8lzhdXqkYHiONwn0gNFVHP/Gu9aBxnNqjMoEa5rZggqsFHufcT9a6QF4qKM0T0PIcsLhUelq1gUxPt6rTuEleVOaJytHryOqhQbf41Ct/i7sQ/XlwZCivIoYCi+dcJotNflON/QfV7WxtttNFGG20MXvwLRUElz4OG7NEAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\frac{d}{d x} \\sin{\\left(x \\right)}$"
      ],
      "text/plain": [
       "d         \n",
       "──(sin(x))\n",
       "dx        "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t = sympy.Derivative(sympy.sin(x), x)\n",
    "t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAD4AAAAVCAYAAAAeql2xAAAABHNCSVQICAgIfAhkiAAAAzhJREFUWIXt10+IllUUBvDfOGWahQYZFVaLpqEMsiiEonYuykVEheQm+oMSZYtcBNo6K0taRBhlIG3KGslwIwOh/QNTpwL7s6gsA51KMkPKRh2nxTkfvr3ffeez/IyBfDYz73me+9z73nPPue/HaUw4vIafMe0kPK7HGB7syor+A9yAY1jaBa+3MYxzuuB1yjGIA5jaBa+5IuvLu+B1StEvsv1yFz2/wm70tgKTCqK5WIc9GBHHZBALaroFeB+/4RB2YhnOapj8drybfiPYi/fwcE33AHpyDSUMigzeWYv3YG1yT9e4N3Ap5jV4WoSjubC3sAJr8Bm2VHQrcoJ9WI1n8XnGtuDMmu/i5IZFJlu+27C9pt2Ra2hqanMwii9VMohVOUfppMxL7rmS4WwcwX5cXeBn5d8b0+QHXFjhz8BG5XoaEpt5QcH3/Mr/08RL7ywtsIK1Oc99+bw8n9cpn+LpyW8rmb2Q5GMdJn0ldYsLXL/Ixq5afAi/47wO3v3pPdhBN0uU1/dYkmM2YfI4Yw7hxxKxPQ2u7DDpUOr6Gvjdyc+oxJZmbC+exx2YWRjbOk1N9V3FU6kdw0c4u4N+jzhNbfg6Tc7tYPBN6ppqcGvyl9Xi9yY3mvwxbBZ3dgvXJvdOhzVwfDNPJFlECR8sEf8045c38KWMVzED80XJjOIXx2v/4hz7YYc1LBQbN5z61R30k1L/bYk80Rpfo/kzsE+5xpvwanrdlc894jN13zhj5uOwaIAzxR19xPgJuyrnWV8iq119doFvdfWb0uQ7f6/TXmxI7ona2FtF16+jdQvcVokNaO4hN+MPsbEXZezu1G8o6Fu4PzVLmgSLRMZG8CaexEvibt1c0T2TRj/hRawUGRjDB9q76wHRUQfEXbpKXC1j6V299xdm/JGax5z0GdZeZq0yvaXhvV4Xje2SBh7RWdeLI3dYdOJNYmeruEfU4kH8iS9EpqcUPB8SPxZ2iYztx6d4XHsznSw26eNKrC9jv+Kagn/rA2VrgZsurrLxTsSEwTLxItd1wetR45+GCYUp4nbYeJI+U8WJHagTve3aCYGj+ET84Nkhmu6/wRWiX60U/eE0/rf4C2Yx6aXXHhECAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\cos{\\left(x \\right)}$"
      ],
      "text/plain": [
       "cos(x)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t.doit()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7.5.2 integrate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACsAAAAYCAYAAABjswTDAAAABHNCSVQICAgIfAhkiAAAAj1JREFUWIXt1j9IVmEUBvBfCiEt0j8sKCqykNCEqC0HIYiMiqJFp6YaaghpiiAX0wYJkgoi0qElWtqMypaQhAb7R9JQFFJWRPaPItNqeF/z6+N+36c3yUEfuMM953nuee77nnveywzCQTzAp3jdwfZpdZQHu1CHNViLZvzA+uk0NRm8x4HpNlEIxajHMKpycMowitMZsZPoxgC+CS/bh+NYONUmq/AFIxgS2iIX9uMXajNiw+jFRbSiHXcj7yWWT6XZuSjHRrTgHSpzcLtivjgjVpKD2ywYPpur8PVI2JMVn4POmGvNa52buJAQL8V3dBTQj6E61ruRjzCKx/5++7YoPD+BIrdwKSHeEJ+xY4Jmj0V+Wz5SZyTti/dH4/1lFGVxW1GDlULvtuAntiU894rQ27m2/QiacAq3Y837WJzP7DLhq3yOQ1F0TejNbHTihbC9b4UW2JrAK8HnaDgXXsdaY1eXMD0KoiVD1IN5ExHlwc74rIYJcMuwG0/wChsKCRqNm61I7/EPOoTVL52EZkXUPMpHqhf6blAwey6lwTEUC+OqK4W2L3pYlJSsE4b0Q6Gx+4Wz/l9WtzYW3J9C+yZq52cnNuMrnmFpjO2N5KupbAa0C+Mw6WOpwJKEeJHxQ6EnO1mND8LWr87KjR19NSnNDgijKAmHhZ3rFmZ4i3DsPo01B7EuU1AujI0hyb92W6KwN4XRTVHbmCNfiTO4J/T1CD4KC9SEBSlqpsYJweyq/1k0LfqFVZvFLGYkfgPmdpBY6lT+0AAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{x^{3}}{3}$"
      ],
      "text/plain": [
       " 3\n",
       "x \n",
       "──\n",
       "3 "
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.integrate(x**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACEAAAAUCAYAAAADU1RxAAAABHNCSVQICAgIfAhkiAAAAadJREFUSInt1cGLT1EUB/CPGWkWamqISUmmphSlxELJ/GYjJcU0/wJ/gOzZ0MiOWBoLO0VWs5hYUJOaBUlmpWaapkb9EJLIYHHu0/Pze2/uz28Wkm/d7nvnnfO933PvOffxF2IcV/EI7/EdtzLitmIFV0q2S7iPRXzCGzzBOWyqI3uaFv6AuQ5EnE6+oyXbFzzGDUyI5GaT3xK2V5GNYhjr0OhAxBSa6C3Z+ip8LyTe6xm82SL68RmTOaTYm3inC0NPZmAdjmED7mT6H0/zs8Kwfg1EnMRHpcxacBYbxY7tx6EkYCKHvGH14+gTRXy7xmc58RRjSnTTT3R7HEdElndrfAZFoQ9iDEOiVfflLNCw+k5MiqLszyFM2JFinheGbnaiVxTZA7zrIG4BL7Abm7sVcVjcfHVHUYVtaV7pVsQYvuFem2+7RA20okdcVlswg7f83qIn0lAiOYib6bkpWq7wncGrNosdxWU8xEu8Fh0xIgpzGafa58Z5v7ZT65hPfgfS+5kKnj24Jv5FTXwVdTOb1hioEtAJLiYRO9eC7E8xJ7L8j38PPwBKMGKsnJFK6gAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{1}{3}$"
      ],
      "text/plain": [
       "1/3"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.integrate(x**2, (x,0,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACEAAAAUCAYAAAADU1RxAAAABHNCSVQICAgIfAhkiAAAAadJREFUSInt1cGLT1EUB/CPGWkWamqISUmmphSlxELJ/GYjJcU0/wJ/gOzZ0MiOWBoLO0VWs5hYUJOaBUlmpWaapkb9EJLIYHHu0/Pze2/uz28Wkm/d7nvnnfO933PvOffxF2IcV/EI7/EdtzLitmIFV0q2S7iPRXzCGzzBOWyqI3uaFv6AuQ5EnE6+oyXbFzzGDUyI5GaT3xK2V5GNYhjr0OhAxBSa6C3Z+ip8LyTe6xm82SL68RmTOaTYm3inC0NPZmAdjmED7mT6H0/zs8Kwfg1EnMRHpcxacBYbxY7tx6EkYCKHvGH14+gTRXy7xmc58RRjSnTTT3R7HEdElndrfAZFoQ9iDEOiVfflLNCw+k5MiqLszyFM2JFinheGbnaiVxTZA7zrIG4BL7Abm7sVcVjcfHVHUYVtaV7pVsQYvuFem2+7RA20okdcVlswg7f83qIn0lAiOYib6bkpWq7wncGrNosdxWU8xEu8Fh0xIgpzGafa58Z5v7ZT65hPfgfS+5kKnj24Jv5FTXwVdTOb1hioEtAJLiYRO9eC7E8xJ7L8j38PPwBKMGKsnJFK6gAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{1}{3}$"
      ],
      "text/plain": [
       "1/3"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i1 = sympy.Integral(x**2, (x,0,1))\n",
    "i1.doit() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADIAAAAYCAYAAAC4CK7hAAAABHNCSVQICAgIfAhkiAAAAntJREFUWIXt1kuIjlEYB/DfuN9yLTPZUaRs5LJjigVKJqKEYkGuJeRSSiGxoBQLCzHkmmsWIjZyW1m4DSUJiUjG5H63OOfL1+t7v/c1Bqn517c4/3Oe//85533Ocz6a8X9jDD7gWxP+/gn2Y/6/Mm8qdEY9uv8h/Up8wZY47oFZOI67eIcGXMRMtGis0Swc/Z1MMzBbKLURcTw3jh9jHzZgJ15G/ggqGmN0ATW/mWw5nMJztIzjkRjn55OvwkNhMxN/1aQPnqF1yvxY+S/3wBLxXYQmUpszn5VRa2uBaJVY0FG4C08S/HQcwKcU4QZswzzUCZ+9gP6YLNT2WVwvET8WbXAsxyYU5fE5OdEvJvpGqMdiVOAeBmWITxBOaV2CXx75mWViD+M12mV4EA7/RtQcnZyswhCcFzbTqWiuGjdzGKyJ4pMS/MHID06Ja4dXwmbyYFPUO1luUaFzTC/idmBZDoMTMbZvgr8jlELblLiaGDc1h8fCuPa2jGegK97jTBy3F96OXjlMHggnW9wSO+GrUAppqBUuepcM/QXCJuqECsrEUeFh6oVpOJ0jpls0uZTgh0d+T0pcS6HlnsrQXxR1bqBnqQWlXse9kZ8ilNjuDBN+tNRrCb7QIK6mxFULL/jxMtorsDlqjBCegVxogxdCp6oXyisLi4UTm53gt0d+VErcVuHrV6bMr4rxV2TcieQ7Ah9xCHOEi/6unEBE2hcpmA/ALTxKzI/HZTwtoTkDa4WNXhAuehL3satcYsOEk6gut6gIV6NhhwQ/WbgDb7E0MTc0eixJ0Vwt+1/CuazEKrBRI/+U5cT6mEzvP+jxV3BbehNoRjOa0cT4DrTZsQaD0h4hAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\sqrt{\\pi}}{2}$"
      ],
      "text/plain": [
       "√π\n",
       "──\n",
       "2 "
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.integrate(sympy.exp(-x**2), (x,0,sympy.oo))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADsAAAAUCAYAAAAz30VQAAAABHNCSVQICAgIfAhkiAAAApxJREFUWIXt182LV1UYB/DPqA2OOY4vNLZIzPeNLX3JUFN0iiLIqE1/QAQhQQhuRHIj4kLSNuGiAXEjkunCSkWDxIgCsUX4Es1MFInoMJqJKeW4eJ6b18v91YzK/BbNFy4P93u+55znuec55zmX/zFex4c4id8xiL2PUF/GdPyNXTVty/EJLuJW2qN4qUb7FD7Gb6ntwweY8l8OnEmHr+PsEJwfrr6Mt1K/qsJvSv4yurEVu/Edtle0c3Ap9QexDSfy/Rym/ZsDqzAPLXh+CM4PV1/G57iCsSXujRzjGNpr+jxWeT+S+vUVfkfyHw3Rl2E7Pxx9h0i57hI3Bj24gSeGMMbsnK83+5bRjj9yrMfLEzQDL6MVB0rcMszCZxhIzUa8i2drxlid9ijuVNqu4xQmYGlBjnsEjj8I1omvfqzELUp7CafxTKXPV+JAvJzvC9JeaDDHj+jCfBynOSs7Hi+KPftnie9M+zbasEak40KxN1dgf0nfkfZag3kKfnJBNCPYLkzEpxW+OKhaxAoeF/vuB5EJv2Kl+pSuQ0vawYJoRrDrcBuHK/xA2h58X2m7KVYXFqctVq5DPSZVdCMe7Fi8ImphNf3Op73aoG/xMdoq+vkN9PPS/rOnRzrYFaLQV1OYOID+Ek621rQvTNuX9su0XepLz3MiI74pyJEO9jVRJg7VtF3BPpGWmytta/GCyIYvkvtJlJ2n8U5Fv0XU1z3i1Me9TVzg1XzgyZygR9x9C4c2PIT+F7Eyy6uRJjpFfZybY3yLmWKfD+JN95/Ic/B19jskrqxLxM3ugqjd/Q3m8n4O2ujpewj9ouTeazR5Yqq47vWKg6w/A1naQD9D3MQupv5n7MxxmoatIthZzXRipHBW/CWNYhSjeHDcBXwotC4+3e5HAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{11}{60}$"
      ],
      "text/plain": [
       "11\n",
       "──\n",
       "60"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.integrate(2-x-y, (y,x*x,x), (x,0,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Si(1)\n",
      "0.946083070367183\n"
     ]
    }
   ],
   "source": [
    "i2 = sympy.Integral(sympy.sin(x)/x, (x,0,1))\n",
    "print(i2.doit())\n",
    "print(sympy.N(i2))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7.5.3 limit"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "E\n"
     ]
    }
   ],
   "source": [
    "print(sympy.limit(sympy.sin(x)/x, x, 0))\n",
    "\n",
    "n = sympy.symbols('n', integer=True)\n",
    "print(sympy.limit((1+1/n)**n, n, sympy.oo))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 7.5.4 series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAO0AAAAYCAYAAAAWEnolAAAABHNCSVQICAgIfAhkiAAABrlJREFUeJztm3uIVFUcxz+jYm5GSmVmVFTUliJZlJKVNmolZKX2INKkMVMCzexFaEhDkVopmpZBRK49BFEz6WFI0JLayy2tJbekjTFKM6WX1Vq7Nf3xPdPcvd7n3Bnv7HI/cJl7z/zOOb/5nfs7j985AwkJCQkxMxvYBvwG7AdeBwbGqlH8zAHywNNxK5IAQD9gJXo/W4BG4PKgmbtUSKk4SQPLgUuAkUAb8A5wXIw6xcnFwFTg87gVSQCgN7AVSAFjgAHALODHOJWqNo4B/gGujVuRGOgFNKPOq55kpI3Ki8i5ekYoYx5yWj8uRLOjKX6CNwLLgM1oepkHXo6gYDXQD/2OS12+74uceql5Ph64A1gPfI2mL78CW5ABO9LsZDXwuLmvx9tpK2WHScj+eVNe3JwJPAZsB34C/gJyQB0wyCPfRcC/wL0R698JLAJWoQ5gBzADjbx21gN70cDjyg5k3INAE53DaVejBurq8v009DtHmOc7zfMe4BVgPvAC8ItJX4uzgauNqcAnQHfzXI+301bCDqca+YPE77QpYC5wCDnfu2iAWgC8bdJagdtd8m9Cv6Umoh6HzDUfuACYDPwOTHeQHYLsNserwBHA2egHpun4Tvsk6qnO8pDZCByg6NQj0VTaPpKcBHyLbHJDCbpkTN50CXnDcg4KcpxrSavH22nLbYcUiiU0o3aI4rQZotkuBawwZWwDah1kRiGnbUPOZKUWOfVzJdZv5W/gA1vafDQCO9EE7MZ90GlHmupw2k1Gj+tt6Sk0pcmj3tLOImAfWui70QtNj1YE1KUQhV0WUN5KhmgvXhg7FOpqs1x59OK1AUfZyqiEHe429Q0HssTrtLNN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F8mZfwYBLyBesAr0dQDZMAG1HMO4/A9ryCMA96nfWi/wG0UI6CbUfDFTo5wwaMoJHaIxmK0Jr4V+BLYgE509UHn0QegyOx49DdOJ9ah01+j0TlsqGy7WLkKtcEGN4Es3muRXEQFgnIWMuTPaO/MTmHD+cMSyh5s8rod/M7ivyarL6HeDOFHi85ih0JZcZ2IAjndW2hUbUUd1XvAPcCxPnm7o3b4yDxXsl2s9EIBqHKN2h2WecigfqdjOjuJHcJR2A6yn0uuJHeZOocdwTqrkibCbbF0VhI7hKMHOjfsNoUuNzVoS3TtEaovIaFTMhwd4I/yJ/ig9EfLitOPQF0JCQkJCQkJCQkJHZX/AL0nlL5csmlnAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle 1 - \\frac{x^{2}}{2} + \\frac{x^{4}}{24} + O\\left(x^{6}\\right)$"
      ],
      "text/plain": [
       "     2    4        \n",
       "    x    x     ⎛ 6⎞\n",
       "1 - ── + ── + O⎝x ⎠\n",
       "    2    24        "
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.cos(x).series()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAUgAAAAYCAYAAACY7WRwAAAABHNCSVQICAgIfAhkiAAACJNJREFUeJztnHuMHVUdxz9bmtoVdYsvHqEqDysl1UKURnzgtjWSgOIDHwFCGKQSDQ8fxGg1xKsGtgrV0gJKY2QLiGmoYuID2/jYWBrUVqlp7AqhdCvYtdaAWKFol17/+P4Odzo7jzNz5+7c3c4nmdw7Z37nnN/85tzfOed3zlyoqampqTlsWApsBv4N7AV+DMyrVKPq+QLQBG6uWpFJxLHAGtSG9gPbgHdUqlFNEUZQ248et1SoU6WsBy5FTvH1wL3A34GXVqlUhbwZ2An8idpB+jILeBS4A1gAnAAsBuZWqVRNIV4BHBM63okcZH+FOnUVLwKe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Sv/UElMR+9bjSKesswm023txcs+zHG73NzXGJlj6F9Z42YIyhQZ0CxRjcV7NCgGgdZle3CbMRvcaaIvaOvGg7QetXwIYq/ahhQ3EFOQ7HoJtpudydaUV+NVqub6Hkk2eMCk4luqerks3R8H9k/caTfID12NNKmAr6cjJban0R7paK4DZ2/LVD2GZY36UX4BtkxtKEC9Qbkb3RTxQ6urIl0kFXazuGmbI+R/eZMg2L2no3e4hlFU89dKObZzog/oP14+floQWovmgLvAX4DfJrWAlIcM9Bz+10orZPP0tGHFmfKGIlOatz2h6xd/lOd2g7FqW3XWdz2n9OzBEvkKsoZhU56hsm3rWaqUtuhOLXtOstMNBL2iduWQS/aLrZuguqrqampaYuz0J9HlP2HuXHMRSGO10xAXTU1NTU1NTU1NTU1NTU1hyP/B24OmIbJaThZAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle 1 - \\frac{x^{2}}{2} + \\frac{x^{4}}{24} - \\frac{x^{6}}{720} + O\\left(x^{7}\\right)$"
      ],
      "text/plain": [
       "     2    4     6        \n",
       "    x    x     x     ⎛ 7⎞\n",
       "1 - ── + ── - ─── + O⎝x ⎠\n",
       "    2    24   720        "
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.cos(x).series(n=7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJ8AAAAYCAYAAADkri+AAAAABHNCSVQICAgIfAhkiAAABAhJREFUaIHt2WtoXEUUwPFfbNBWKi2+qqAfhIoPxPpFUVFJoyIIatWCWBAXaougqIgiCoXFDyrWYm2lQhGN+IDSgoJKRUQCUREabTFgUIwEP7RKi6+Kz2r8MLNks+7dvXd3szcb7x8G7p05c+bs2TMzZ+ZSUDAPeARTeDZvQ3qEh7EHP+Mg3sR5uVrUZY7qkJ6LsQ6fdUjf/4EBbMOlGMQRvIfjc7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T+hvax57jaccqyKrm6ufPPFd9WUtLfyNbNrskW9mXksDnhGtwacRxS+a5NxXTiez1MK3xUUFBQUFBQUFPQ8/wLBnKo8D5hPUgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\frac{x^{4}}{24} - \\frac{x^{2}}{2} + 1$"
      ],
      "text/plain": [
       " 4    2    \n",
       "x    x     \n",
       "── - ── + 1\n",
       "24   2     "
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.cos(x).series(n=5).removeO()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAUCAYAAACXtf2DAAAABHNCSVQICAgIfAhkiAAAATRJREFUOI3t1D0oRnEUBvDf66XMYlIMJhLlIwsLkplYZbHZDGKxWSklmUxKBossFoXJgkEyK/QmKcpHGO5f3d7ee329xeCp27n/c57znHPuPffyxzGEB9TGfPM4Q1UxCmRwgOVwnsAl6ooh/o4+PGESt2grpvg79vGM/s8mDGILOTyKnukUsgW43bjDC1o+Es5iFa9BdBFzOA2+lTx+M24wgo3QVCoWgtAsSmP+MuyFWEPw1eIc0+HcFKboShLvCISNhPhYKDCKCpxgKY+zht24I97luGjt7jFToEBjsBlco74AZzipe7gKHX509aaJJKE8JO98JzkNJcFmgq0sdoE4DkVTDCTEOxX+DlKRid33YVP04rdxJJqwGq2iVa35aoF8tGMdF6L/Sw7HonXs+an4P34HbzoIQlPXF1sbAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle e^{x}$"
      ],
      "text/plain": [
       " x\n",
       "ℯ "
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr9 = x**n / sympy.factorial(n)\n",
    "sympy.Sum(expr9, (n,0,sympy.oo)).doit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACsAAAAYCAYAAABjswTDAAAABHNCSVQICAgIfAhkiAAAAmZJREFUWIXt1lnojmkYBvCffekvIcuBlKJkyZa1TCEpMkUj5UxKOSQpJVGibAcS5UTORoZpkmwlZqYUB2PJLpQDZBtjMGM/uJ+P1+Nb+PyRuOrr+bru5bme+37v5335RrAIx/APbmEX+n9RRVWwD7OEwAH4FTfQ8UuKel804DmmfKoNmjZirnYp390qPl3FgdaXsY3BDlzH/2ndj0mNqPE1tuEvNKviMwcvMTbjFyf+FrZgBTaLmVjV2EJXi0r0quG3B7e9faDpSegB0Z0cLcolmpyC3uc3qBC3FjfRt4bQ9qK9WwpcU1zGQ3SuEa954f99bMJcnMYvBVsfzMCfogInE78+8WNxpsZek9ESOwvcaPRMe91LPv3xH47iSLWEU0Xllmf8wsTPLnAbxR07Dt0Kv4YKubfjX7QucPNS3g2iAHkHD6tS8WXJ6aeM/znxQwtcpUdkaZm8rfEgCS5iZYp5hosYLw7bD3uT7VAlsb8lh94ZfwFP0apSYA38mPLOzPhViX+OgZmtDa4l+yjevWcHiVZdKnANYsrPiQGpB1PxBLsz/l5aL+NEZnss3pIwPBfbAT28eXZKGIwmOF6n0GbirXZQDHER59P6d4XY0mHa5GJL11F+wiFprVfsD+gkvh1y/C6e197ipshR+jC6SnmxuahSwKk6hMI0vBDzkOO2ePO1x5LMNgETRTf25oFbRftHZPyOxM9D9zrEXsMfVexdxE3wUlR6jbg1nomhnl4u6LiYyrYZP0NU4BEWfKDQYUnE/Bp+HbEOV8Qg3hGdGPmB+30UVgixPT/npvXirPoH8zu+46vHK8fooVfyCVxFAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\pi^{2}}{6}$"
      ],
      "text/plain": [
       " 2\n",
       "π \n",
       "──\n",
       "6 "
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = sympy.Sum(1/(n**2), (n,1,sympy.oo))\n",
    "s.doit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAACcAAAASCAYAAADYFMcrAAAABHNCSVQICAgIfAhkiAAAAb9JREFUSInt1U2IjVEYB/AfWRHjK1mwcZuxsSerMRsrpdhiwUKJFKWUsjMr0VhYYWF2ChthIeVjpVjIxxCXxaCQMT7yeS3Oc3V757z3vbizmPKvt+e8z/N/zvmf03mewxTCRgzhGt6jgdMl3AXYhrN4jM8Yw3VsxfQ26yzBCYziC+o4gnntxN0JQeO4XyFue8RHMYxDseC78J/BtExeDa+Ccw6DuBL/D2LTWaxBb0zaXyFuAOtMPKHFeB65GzJ5lyK2s+A/HP7jZeJaUSWuHfZH7lDBvyz8T03c1Gx8wEfMkiF0C9/Cfi/4B8Jexs9CbBw3MBOrJkvcDGyO8cVCbHnYkZLcR2H7mBxxg1iBC9L9akVP2LGS3KZ/Lt0Xtwt7pKrb9Bf5zepu0F1xO3AU96Sqf5vhNE+mJxODOa28bonbjWO4G8JelvAehu0rifeGLbuTv9Gvs1ayL3i3sbCCW1PdSj6JVvKv4g4E5xbmV00Y6LgJF5+X9fGROv1aPJHeWniNvTHeglP4ITXbXAXWg9OKGm5iEc5Lz+RK6TqMYDXe5HZ1MNSXffU/4DZwNbcIluIkXuArnknF1Onp/8fUxS915n9xIf76TgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle 120$"
      ],
      "text/plain": [
       "120"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expr8 = sympy.Product(n, (n,1,5))\n",
    "expr8.doit()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.6 equation\n",
    "\n",
    "non-linear equation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAADoAAAAVCAYAAAAXQf3LAAAABHNCSVQICAgIfAhkiAAAAc1JREFUWIXt10+oTVEUx/EPvYGJIgbKwMiMmBo5j6FeEUN/3lApKcpIPSZkImVghAEzs1di8hwZiyKUyc1AL0miJP+uwd63e95551z73HcvDr61O7t99lp7/fb5s9fiHyRDt9Ce/9ZohmOthRq6vRsTFZPvIceb0vg+bMdWbMFK3MD+kYfbZw32YBc2Yz0+4zGuxva9MP8jTsf+NDZUOc2EHZipWfRRvP8Bz2L/+rAKEjkc13klbOpZXMG7OH4Ty2psc4UnWiQzWOgkNkbHvbnjFroDU1heGl+HlzGGvTW2uYLQsoNB3MULNbs0JuYwa+HrCfO4HPtZiqMmQv80vsTr15TJbRU6gYOxfzvFoK1Cz2ETbuFOikEbhR7FceGcP5Bq1DahR3ART4VT4G2qYZuEHsMlPBFEzjcxbovQk7ggJC2TeN3UwbiFXhPO3ekl+Dgl/HweYKfFqWkSVbluHbtjI2QmsE0QIwZwomTT28iks66CQziDb7gv/IjKdAoxJJEZnALOWFwZFFunwuYh3mN1k0AarNkVUr0qckPmuk1ZJTyJ8yPy15TcT4SOqh6dwif91/xXkFSPdvRrOYb86AvMYsUSfTSlWI/+56/mB+l0ekO6m+h2AAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left[ 1, \\  2\\right]$"
      ],
      "text/plain": [
       "[1, 2]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.solve(x**2-3*x+2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeYAAAAgCAYAAADHVdvSAAAABHNCSVQICAgIfAhkiAAACrZJREFUeJztnX3QFVUdxz/Cg0KAQUlERFxrMh3TJCylt3nAQk0fEQtzLO1KThY2jKOZvYz1xIzl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+oDNL0Ut2OFi6YhZyLVqMe/fFo/GsIjWF5xxsbvX2bq2Vlidc+OG3bpaz6zlPbkE7feWk7EjWivTE3SPIJJIg3mXtfixaPvx1NJt+Jehy9KeKuY++NeRRans1RftrV37egenN+wPl+2k8dWeO5ZgJyLNqOpmisQ04h00x4vy9Rm5AOxrdJb6fRyN8stQ329O20XS3S6LuffLRdw+KnbIejG2islnRggWkYh3rt3nmuDocjHZ2g7xoR2tzJaFHwdeiz0g2ZJ8vh6FweJd50uizoQ5+//FYTcjgcySlS3wtQG7satbnzCkqHw+FwOBwOh8PhcDgcDofD4XA4HA6Hw+FwOErM/wBOAU2tYK/NXgAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\left[ \\frac{- b + \\sqrt{- 4 a c + b^{2}}}{2 a}, \\  - \\frac{b + \\sqrt{- 4 a c + b^{2}}}{2 a}\\right]$"
      ],
      "text/plain": [
       "⎡        _____________   ⎛       _____________⎞ ⎤\n",
       "⎢       ╱           2    ⎜      ╱           2 ⎟ ⎥\n",
       "⎢-b + ╲╱  -4⋅a⋅c + b    -⎝b + ╲╱  -4⋅a⋅c + b  ⎠ ⎥\n",
       "⎢─────────────────────, ────────────────────────⎥\n",
       "⎣         2⋅a                     2⋅a           ⎦"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.solve(a*x**2 + b*x + c, x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPAAAAAZCAYAAAAPHqPYAAAABHNCSVQICAgIfAhkiAAACGBJREFUeJztnH+wVVUVxz8XjHghYJqNOVpIhlgalU1OVgLBWFmOTViNaXENaoqwxmoqbMpXSZC/IksrZqTrr1EZDCeylEymkMZCB4sJpBl6RxMIGH+AKA8eefvju86cc/fb+9577r2Pc59zvjNn7jtrrb32uufstfbaa+/7oECBAi8rPAQs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Relx1ehdex/jJc+rPEWo9Vbf9xuMl9y6DOQc/SjivVi4PfI2fsYPPCzyp9t/T6Fyvy91G5ljUBFqSqaSW9F1cKlqNpcRSnieYHvdaHJfKMB3/3eU1A9YAeK3GmstzbvC+jME91gd5n2HPijyCErqGoeB/CY5tuLvcXkLvbw0nCPUi4iOUq5Bf9RSpBvHUJnE1xEtHCU8ly037oNpUrPoAG9HM1maUPiNPWmUCckEfpBD2+q0ffZtRGdpQ6dAssqPx89vH6zYaFHZhbwO5IfbOwE/oxm8HEe+Rjx3p+bEcQYhbYG/pqinWy0Z9Ea3UW8qf9wnX7zQLfYXaY9B+6lfiU78rTZgAJ86AcJaZyIjubuQL7zBPATwj86GY+KV6HsJaIFBy7QOcTbT74z1AW6H0eh2stVQ6T/UupnLhGFA+eK0SgKFz9cH544D2Vvxw2B7h60c7KijkxEnX3gdahwdQD4eoeNKyD0o/9AMR1VIF/I15wCGbGK5vbyW8EEVG+peHhzUSF5K1q2FChQoECBAgUKFChQIBv+DxHK83Oj63qHAAAAAElFTkSuQmCC\n",
      "text/latex": [
       "$\\displaystyle \\left[ \\operatorname{CRootOf} {\\left(x^{5} - x^{2} + 1, 0\\right)}\\right]$"
      ],
      "text/plain": [
       "⎡       ⎛ 5    2       ⎞⎤\n",
       "⎣CRootOf⎝x  - x  + 1, 0⎠⎦"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.solve(x**5 - x**2 + 1, x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "ename": "NotImplementedError",
     "evalue": "multiple generators [x, tan(x)]\nNo algorithms are implemented to solve equation x + tan(x)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNotImplementedError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_14988\\518625754.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0msympy\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msolve\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msympy\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtan\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\sympy\\solvers\\solvers.py\u001b[0m in \u001b[0;36msolve\u001b[1;34m(f, *symbols, **flags)\u001b[0m\n\u001b[0;32m   1169\u001b[0m     \u001b[1;31m###########################################################################\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1170\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mbare_f\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1171\u001b[1;33m         \u001b[0msolution\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_solve\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0msymbols\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mflags\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1172\u001b[0m     \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1173\u001b[0m         \u001b[0msolution\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_solve_system\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mf\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msymbols\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mflags\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\sympy\\solvers\\solvers.py\u001b[0m in \u001b[0;36m_solve\u001b[1;34m(f, *symbols, **flags)\u001b[0m\n\u001b[0;32m   1740\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1741\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mresult\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mFalse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1742\u001b[1;33m         \u001b[1;32mraise\u001b[0m \u001b[0mNotImplementedError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'\\n'\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mmsg\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnot_impl_msg\u001b[0m \u001b[1;33m%\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1743\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1744\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mflags\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'simplify'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNotImplementedError\u001b[0m: multiple generators [x, tan(x)]\nNo algorithms are implemented to solve equation x + tan(x)"
     ]
    }
   ],
   "source": [
    "sympy.solve(sympy.tan(x) + x, x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{2 n \\pi + \\frac{\\pi}{2}\\; |\\; n \\in \\mathbb{Z}\\right\\}$"
      ],
      "text/plain": [
       "⎧        π        ⎫\n",
       "⎨2⋅n⋅π + ─ | n ∊ ℤ⎬\n",
       "⎩        2        ⎭"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sympy.solveset(sympy.sin(x) - 1, x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "equations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJEAAAAXCAYAAAALMa3mAAAABHNCSVQICAgIfAhkiAAABDVJREFUaIHt2mmoVVUUB/CfaUUDpY0298FKKxqgETJuoSCFNFgfCsqiqKAw0yIJwkdlaigENhiCPEi/RNBkINGgqSVlWZkYFPGoKKNJk7J61evD2tf7et7hnHvfvb6n9w+Hc+/Zazrr7LP22msd2mijybgea7EV/+CsXWtOGy1GB7qxGS/i5LwCTsW/2IbFeBgj+8++AYdrsACr8Ct6sGSXWtR/OBS34gV8ge0iMKzGLdirAl8Bc7Bc+OO9v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6D/cSuq3fIa3+U1j84XkT6RaLB+qnmF2jrQYf/P/+Z5YiqJdbbcY74jGCMSPo296uJey4miKR4i1gmpoqd7kDDCpFI/4R3xTdXbbTRRhtttLE74j8Gei+TozyvMAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\left\\{ x : -1, \\  y : 2\\right\\}$"
      ],
      "text/plain": [
       "{x: -1, y: 2}"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eq1 = x + 2*y - 3\n",
    "eq2 = x - y + 3\n",
    "sympy.solve([eq1,eq2], [x,y])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "linear system\n",
    "\n",
    "can give fundamental solution system of underdetermined equation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left\\{ x_{1} : x_{3} - \\frac{19}{3}, \\  x_{2} : \\frac{20}{3} - 2 x_{3}\\right\\}$"
      ],
      "text/plain": [
       "{x₁: x₃ - 19/3, x₂: 20/3 - 2⋅x₃}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_vars = sympy.symbols('x1, x2, x3')\n",
    "A = sympy.Matrix([[1,2,3], [4,5,6]])\n",
    "x = sympy.Matrix(x_vars)\n",
    "b = sympy.Matrix([7,8])\n",
    "sympy.solve(A*x-b, x_vars)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "differential equation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle f{\\left(x \\right)} = \\left(C_{1} + C_{2} x\\right) e^{x}$"
      ],
      "text/plain": [
       "                    x\n",
       "f(x) = (C₁ + C₂⋅x)⋅ℯ "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f = sympy.Function('f')\n",
    "sympy.dsolve(f(x).diff(x, x) - 2*f(x).diff(x) + f(x))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.7 linear algbra"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}a & b\\\\c & d\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡a  b⎤\n",
       "⎢    ⎥\n",
       "⎣c  d⎦"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a,b,c,d = sympy.symbols('a b c d')\n",
    "M = sympy.Matrix([[a,b], [c,d]])\n",
    "M"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}a^{2} + b c & a b + b d\\\\a c + c d & b c + d^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "⎡ 2                  ⎤\n",
       "⎢a  + b⋅c   a⋅b + b⋅d⎥\n",
       "⎢                    ⎥\n",
       "⎢                  2 ⎥\n",
       "⎣a⋅c + c⋅d  b⋅c + d  ⎦"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "M*M"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7.8 number theory"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120\n",
      "{2: 2, 3: 1, 5: 1}\n",
      "4\n",
      "True\n",
      "[1, 2, 3, 4, 6, 12]\n"
     ]
    }
   ],
   "source": [
    "print(sympy.factorial(5))\n",
    "print(sympy.factorint(60)) #60=2^2*3*5\n",
    "print(sympy.totient(12)) #Euler function\n",
    "print(sympy.isprime(29))\n",
    "print(sympy.divisors(12))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Homework\n",
    "\n",
    "1. Solving equations with summation    \n",
    "?\n",
    "\n",
    "2. Use the simply.limit function to find these three limits separately:\n",
    "\n",
    "$\\lim\\limits_{x \\to 0}\\frac{\\sin x}{x}=1$\n",
    "\n",
    "$\\lim\\limits_{x \\to 0}(1+x)^\\frac{1}{x}=e$\n",
    "\n",
    "$\\lim\\limits_{x \\to \\infty}(1+\\frac{1}{x})^x=e$\n",
    "\n",
    "3. Take partial derivatives of multivariate functions with respect to x and y respectively:\n",
    "\n",
    "$f(x)=x^2+2x+y^3$\n",
    "\n",
    "4. Finding definite integral \n",
    "\n",
    "(1)\n",
    "$\\int_0^3f(x)dx\\$   \n",
    "\n",
    "Among them:\n",
    "\n",
    "$f(x)=\\int_0^x 2xdx\\$ \n",
    "\n",
    "(2)\n",
    "$\\int_0^3 \\cos^2\\(e^x)dx\\$ \n",
    "\n",
    "(3)\n",
    "$\\int_0^{0.5}dy \\int_0^\\sqrt{1-4y^2}16xydx\\$ \n",
    "\n",
    "5. Solving indefinite integrals \n",
    "\n",
    "$\\int (e^x+2x)dx\\$ "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
